diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java index 62987e611b3..b3084a03527 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java @@ -37,8 +37,8 @@ import org.eclipse.core.runtime.IProgressMonitor; public class CoreModel { private static CoreModel cmodel = null; - private static CModelManager manager = null; - private static PathEntryManager pathEntryManager = null; + private static CModelManager manager = CModelManager.getDefault(); + private static PathEntryManager pathEntryManager = PathEntryManager.getDefault(); public final static String CORE_MODEL_ID = CCorePlugin.PLUGIN_ID + ".coremodel"; //$NON-NLS-1$ /** @@ -196,7 +196,7 @@ public class CoreModel { /** * Return the list of headers extensions. */ - public String[] getHeaderExtensions() { + public static String[] getHeaderExtensions() { ICFileTypeResolver resolver = CCorePlugin.getDefault().getFileTypeResolver(); ICFileTypeAssociation[] associations = resolver.getFileTypeAssociations(); ArrayList list = new ArrayList(associations.length); @@ -214,7 +214,7 @@ public class CoreModel { /** * Returns the list of source extensions. */ - public String[] getSourceExtensions() { + public static String[] getSourceExtensions() { ICFileTypeResolver resolver = CCorePlugin.getDefault().getFileTypeResolver(); ICFileTypeAssociation[] associations = resolver.getFileTypeAssociations(); ArrayList list = new ArrayList(associations.length); @@ -232,7 +232,7 @@ public class CoreModel { /** * Returns the list of headers and sources extensions */ - public String[] getTranslationUnitExtensions() { + public static String[] getTranslationUnitExtensions() { ICFileTypeResolver resolver = CCorePlugin.getDefault().getFileTypeResolver(); ICFileTypeAssociation[] associations = resolver.getFileTypeAssociations(); ArrayList list = new ArrayList(associations.length); @@ -733,7 +733,7 @@ public class CoreModel { * @exception CModelException * if the entries could not be set. Reasons include: */ - public void setRawPathEntries(ICProject cproject, IPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException { + public static void setRawPathEntries(ICProject cproject, IPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException { pathEntryManager.setRawPathEntries(cproject, newEntries, monitor); } @@ -748,7 +748,7 @@ public class CoreModel { * while accessing its corresponding resource * @see IPathEntry */ - public IPathEntry[] getRawPathEntries(ICProject cproject) throws CModelException { + public static IPathEntry[] getRawPathEntries(ICProject cproject) throws CModelException { return pathEntryManager.getRawPathEntries(cproject); } @@ -767,7 +767,7 @@ public class CoreModel { * @exception CModelException * @see IPathEntry */ - public IPathEntry[] getResolvedPathEntries(ICProject cproject) throws CModelException { + public static IPathEntry[] getResolvedPathEntries(ICProject cproject) throws CModelException { return pathEntryManager.getResolvedPathEntries(cproject); } @@ -790,14 +790,47 @@ public class CoreModel { return pathEntryManager.getPathEntryContainerInitializer(containerID); } + /** + * Validate a given path entries for a project, using the following rules: + * + * + * Note that the entries are not validated automatically. Only bound variables or containers are considered + * in the checking process (this allows to perform a consistency check on an entry which has references to + * yet non existing projects, folders, ...). + *

+ * This validation is intended to anticipate issues prior to assigning it to a project. In particular, it will automatically + * be performed during the setting operation (if validation fails, the classpath setting will not complete) + * and during getResolvedPathEntries. + *

+ * @param cProject the given C project + * @param PathEntry entries + * @return a status object with code IStatus.OK if + * the entries location are compatible, otherwise a status + * object indicating what is wrong with them + */ + //private static ICModelStatus validatePathEntry(ICProject cProject, IPathEntry[] entries) { + //pathEntryManager.validatePathEntry(cproject, entries) + // return null; + //} + /** * Return the singleton. */ public static CoreModel getDefault() { if (cmodel == null) { cmodel = new CoreModel(); - manager = CModelManager.getDefault(); - pathEntryManager = PathEntryManager.getDefault(); } return cmodel; }