From 4452556357acac89a57e33f3fe41da44d490cab4 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Thu, 20 May 2004 19:52:57 +0000 Subject: [PATCH] Making the CProblem markers persistent across sessions. --- .../cdt/internal/core/model/APathEntry.java | 8 +++-- .../cdt/internal/core/model/IncludeEntry.java | 8 +++-- .../cdt/internal/core/model/LibraryEntry.java | 4 ++- .../cdt/internal/core/model/MacroEntry.java | 8 +++-- .../cdt/internal/core/model/PathEntry.java | 2 +- .../internal/core/model/PathEntryManager.java | 36 +++++++++++++++---- core/org.eclipse.cdt.core/plugin.xml | 8 ++--- .../core/CCorePluginResources.properties | 5 +++ 8 files changed, 61 insertions(+), 18 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/APathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/APathEntry.java index 13b863f71f5..9b216dee2bd 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/APathEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/APathEntry.java @@ -124,8 +124,12 @@ public abstract class APathEntry extends PathEntry { public String toString() { StringBuffer sb = new StringBuffer(); sb.append(super.toString()); - sb.append(" base-path:").append(basePath.toString()); //$NON-NLS-1$ - sb.append(" base-ref:").append(baseRef.toString()); //$NON-NLS-1$ + if (basePath != null && !basePath.isEmpty()) { + sb.append(" base-path:").append(basePath.toString()); //$NON-NLS-1$ + } + if (baseRef != null && !baseRef.isEmpty()) { + sb.append(" base-ref:").append(baseRef.toString()); //$NON-NLS-1$ + } return sb.toString(); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java index c951955aacf..b1e6247a776 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java @@ -103,8 +103,12 @@ public class IncludeEntry extends APathEntry implements IIncludeEntry { public String toString() { StringBuffer sb = new StringBuffer(); sb.append(super.toString()); - sb.append(" isSystemInclude:").append(isSystemInclude); //$NON-NLS-1$ - sb.append(" includePath:").append(includePath); //$NON-NLS-1 + if (isSystemInclude) { + sb.append(" isSystemInclude:").append(isSystemInclude); //$NON-NLS-1$ + } + if (includePath != null && !includePath.isEmpty()) { + sb.append(" includePath:").append(includePath); //$NON-NLS-1$ + } return sb.toString(); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java index 4f69b8516db..9e34570794a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java @@ -162,7 +162,9 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry { public String toString() { StringBuffer sb = new StringBuffer(); sb.append(super.toString()); - sb.append(" librarypath:").append(libraryPath.toString()); //$NON-NLS-1$ + if (libraryPath != null && !libraryPath.isEmpty()) { + sb.append(" librarypath:").append(libraryPath.toString()); //$NON-NLS-1$ + } return sb.toString(); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java index a8918be56b1..62dfcd9c44d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java @@ -80,8 +80,12 @@ public class MacroEntry extends APathEntry implements IMacroEntry { public String toString() { StringBuffer sb = new StringBuffer(); sb.append(super.toString()); - sb.append(" name:").append(macroName); //$NON-NLS-1$ - sb.append(" value:").append(macroValue); //$NON-NLS-1$ + if (macroName != null && macroName.length() > 0) { + sb.append(" name:").append(macroName); //$NON-NLS-1$ + } + if (macroValue != null && macroValue.length() > 0) { + sb.append(" value:").append(macroValue); //$NON-NLS-1$ + } return sb.toString(); } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntry.java index 661b1669609..20c81730cd9 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntry.java @@ -120,7 +120,7 @@ public class PathEntry implements IPathEntry { */ public String toString() { StringBuffer buffer = new StringBuffer(); - if (path != null) { + if (path != null && !path.isEmpty()) { buffer.append(path.toString()).append(' '); } buffer.append('['); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java index 492d8976c6b..f79faaa610b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java @@ -975,7 +975,9 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange continue; } if (entry != otherEntry && otherEntry.equals(entry)) { - return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, "Duplication:" + entry.toString()); //$NON-NLS-1$ + StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceBundle().getString("CoreModel.PathEntry.DuplicateEntry")); //$NON-NLS-1$ + errMesg.append(':').append(entry.toString()); + return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString()); } } } @@ -1003,13 +1005,19 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange String exclusionPattern = entryPath.removeFirstSegments(otherPath.segmentCount()).segment(0); if (CoreModelUtil.isExcluded(entryPath, exclusionPatterns)) { - return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, "Nested:" + entry.toString()); //$NON-NLS-1$ + StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceBundle().getString("CoreModel.PathEntry.NestedEntry")); //$NON-NLS-1$ + errMesg.append(':').append(entry.toString()); + return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString()); } else { if (otherKind == IPathEntry.CDT_SOURCE) { exclusionPattern += '/'; - return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, "Nested:" + entry.toString()); //$NON-NLS-1$ + StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceBundle().getString("CoreModel.PathEntry.NestedEntry")); //$NON-NLS-1$ + errMesg.append(':').append(entry.toString()); + return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString()); } else { - return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, "Nested:" + entry.toString()); //$NON-NLS-1$ + StringBuffer errMesg = new StringBuffer(CCorePlugin.getResourceBundle().getString("CoreModel.PathEntry.NestedEntry")); //$NON-NLS-1$ + errMesg.append(':').append(entry.toString()); + return new CModelStatus(ICModelStatusConstants.INVALID_PATHENTRY, errMesg.toString()); //$NON-NLS-1$ } } } @@ -1023,8 +1031,10 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange public ICModelStatus validatePathEntry(ICProject cProject, IPathEntry entry, boolean checkSourceAttachment, boolean recurseInContainers){ IProject project = cProject.getProject(); - IPath projectPath = cProject.getPath(); - String entryMesg = projectPath.toString() + ": " + entry.toString(); //$NON-NLS-1$ + StringBuffer sb = new StringBuffer(); + sb.append(CCorePlugin.getResourceBundle().getString("CoreModel.PathEntry.InvalidPathEntry")); //$NON-NLS-1$ + sb.append(':').append(entry.toString()); + String entryMesg = sb.toString(); switch(entry.getEntryKind()) { case IPathEntry.CDT_INCLUDE: { IIncludeEntry include = (IIncludeEntry)entry; @@ -1103,6 +1113,20 @@ public class PathEntryManager implements IPathEntryStoreListener, IElementChange break; } case IPathEntry.CDT_CONTAINER: + if (recurseInContainers) { + try { + IPathEntryContainer cont = getPathEntryContainer((IContainerEntry)entry, cProject); + IPathEntry[] contEntries = cont.getPathEntries(); + for (int i = 0; i < contEntries.length; i++) { + ICModelStatus status = validatePathEntry(cProject, contEntries[i], checkSourceAttachment, false); + if (!status.isOK()) { + return status; + } + } + } catch (CModelException e) { + return new CModelStatus(e); + } + } break; } return CModelStatus.VERIFIED_OK; diff --git a/core/org.eclipse.cdt.core/plugin.xml b/core/org.eclipse.cdt.core/plugin.xml index 6b110816068..eb4df667400 100644 --- a/core/org.eclipse.cdt.core/plugin.xml +++ b/core/org.eclipse.cdt.core/plugin.xml @@ -154,6 +154,9 @@ + + @@ -372,7 +375,7 @@ - + - - diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties index 84b8b89e92c..db9cb1cf2b1 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CCorePluginResources.properties @@ -14,6 +14,11 @@ CoreModel.CModelStatus.Error_in_CPlugin=Error in C Plugin CoreModel.NullBinaryParser.Not_binary_file=not a binary file CoreModel.NullBinaryParser.Null_Format=Null Format +CoreModel.PathEntry.IllegalContainerPath= Illegal container entry +CoreModel.PathEntry.DuplicatedEntry= Duplicate path entries +CoreModel.PathEntry.NestedEntry= Nested path entries +CoreModel.PathEntry.InvalidPathEntry= Invalid path + CommandLauncher.error.commandCanceled=Command canceled CCProjectNature.exception.noNature=Project must have a cnature