mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Refactor ICPathEntry to IPathEntry.
And use a manager PathEntryManager to deal with the IPathEntries
This commit is contained in:
parent
d2990e8a84
commit
31196e5d83
26 changed files with 1047 additions and 1078 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2004-02-21 Alain Magloire
|
||||||
|
|
||||||
|
Refactor the ICPathEntry to IPathEntry for consistency.
|
||||||
|
Regroup the IPathEntry helper methods in PathEntryManager
|
||||||
|
To much files change in the refactoring to enumerate.
|
||||||
|
|
||||||
2004-02-17 David Inglis
|
2004-02-17 David Inglis
|
||||||
Fix PR 52095
|
Fix PR 52095
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.eclipse.cdt.internal.core.model.ContainerEntry;
|
||||||
import org.eclipse.cdt.internal.core.model.IncludeEntry;
|
import org.eclipse.cdt.internal.core.model.IncludeEntry;
|
||||||
import org.eclipse.cdt.internal.core.model.LibraryEntry;
|
import org.eclipse.cdt.internal.core.model.LibraryEntry;
|
||||||
import org.eclipse.cdt.internal.core.model.MacroEntry;
|
import org.eclipse.cdt.internal.core.model.MacroEntry;
|
||||||
|
import org.eclipse.cdt.internal.core.model.PathEntryManager;
|
||||||
import org.eclipse.cdt.internal.core.model.ProjectEntry;
|
import org.eclipse.cdt.internal.core.model.ProjectEntry;
|
||||||
import org.eclipse.cdt.internal.core.model.SourceEntry;
|
import org.eclipse.cdt.internal.core.model.SourceEntry;
|
||||||
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
|
||||||
|
@ -29,6 +30,7 @@ public class CoreModel {
|
||||||
|
|
||||||
private static CoreModel cmodel = null;
|
private static CoreModel cmodel = null;
|
||||||
private static CModelManager manager = null;
|
private static CModelManager manager = null;
|
||||||
|
private static PathEntryManager pathEntryManager = null;
|
||||||
|
|
||||||
public final static String CORE_MODEL_ID = CCorePlugin.PLUGIN_ID + ".coremodel"; //$NON-NLS-1$
|
public final static String CORE_MODEL_ID = CCorePlugin.PLUGIN_ID + ".coremodel"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
@ -159,14 +161,17 @@ public class CoreModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns a new non-exported entry of kind <code>CDT_PROJECT</code> for the project identified by the given
|
* Creates and returns a new non-exported entry of kind <code>CDT_PROJECT</code>
|
||||||
* absolute path.
|
* for the project identified by the given absolute path.
|
||||||
* <p>
|
* <p>
|
||||||
* A project entry is used to denote a prerequisite project. The ICPathEntry[] entries of the project will be contributed.
|
* A project entry is used to denote a prerequisite project. The
|
||||||
|
* IPathEntry[] entries of the project will be contributed.
|
||||||
* <p>
|
* <p>
|
||||||
* The prerequisite project is referred to using an absolute path relative to the workspace root.
|
* The prerequisite project is referred to using an absolute path relative
|
||||||
|
* to the workspace root.
|
||||||
* <p>
|
* <p>
|
||||||
* The resulting entry is not exported to dependent projects. This method is equivalent to <code>newProjectEntry(path,false)</code>.
|
* The resulting entry is not exported to dependent projects. This method
|
||||||
|
* is equivalent to <code>newProjectEntry(path,false)</code>.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param path
|
* @param path
|
||||||
|
@ -180,16 +185,20 @@ public class CoreModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns a new entry of kind <code>CDT_PROJECT</code> for the project identified by the given absolute path.
|
* Creates and returns a new entry of kind <code>CDT_PROJECT</code> for
|
||||||
|
* the project identified by the given absolute path.
|
||||||
* <p>
|
* <p>
|
||||||
* A project entry is used to denote a prerequisite project. All the ICPathEntries of the project will be contributed as a
|
* A project entry is used to denote a prerequisite project. All the
|
||||||
* whole. The prerequisite project is referred to using an absolute path relative to the workspace root.
|
* IPathEntries of the project will be contributed as a whole. The
|
||||||
|
* prerequisite project is referred to using an absolute path relative to
|
||||||
|
* the workspace root.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param path
|
* @param path
|
||||||
* the absolute path of the prerequisite project
|
* the absolute path of the prerequisite project
|
||||||
* @param isExported
|
* @param isExported
|
||||||
* indicates whether this entry is contributed to dependent projects in addition to the output location
|
* indicates whether this entry is contributed to dependent
|
||||||
|
* projects in addition to the output location
|
||||||
* @return a new project entry
|
* @return a new project entry
|
||||||
*/
|
*/
|
||||||
public static IProjectEntry newProjectEntry(IPath path, boolean isExported) {
|
public static IProjectEntry newProjectEntry(IPath path, boolean isExported) {
|
||||||
|
@ -197,10 +206,13 @@ public class CoreModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns a new entry of kind <code>CDT_CONTAINER</code> for the given path. The path of the container will be
|
* Creates and returns a new entry of kind <code>CDT_CONTAINER</code> for
|
||||||
* used during resolution so as to map this container entry to a set of other entries the container is acting for.
|
* the given path. The path of the container will be used during resolution
|
||||||
|
* so as to map this container entry to a set of other entries the
|
||||||
|
* container is acting for.
|
||||||
* <p>
|
* <p>
|
||||||
* The resulting entry is not exported to dependent projects. This method is equivalent to <code>newContainerEntry(path,false)</code>.
|
* The resulting entry is not exported to dependent projects. This method
|
||||||
|
* is equivalent to <code>newContainerEntry(path,false)</code>.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param containerPath
|
* @param containerPath
|
||||||
|
@ -208,87 +220,94 @@ public class CoreModel {
|
||||||
* @return a new container entry
|
* @return a new container entry
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static IContainerEntry newContainerEntry(String id) {
|
public static IContainerEntry newContainerEntry(IPath id) {
|
||||||
return newContainerEntry(id, false);
|
return newContainerEntry(id, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns a new entry of kind <code>CDT_CONTAINER</code> for the given path. The path of the container will be
|
* Creates and returns a new entry of kind <code>CDT_CONTAINER</code> for
|
||||||
* used during resolution so as to map this container entry to a set of other entries the container is acting for.
|
* the given path. The path of the container will be used during resolution
|
||||||
|
* so as to map this container entry to a set of other entries the
|
||||||
|
* container is acting for.
|
||||||
* <p>
|
* <p>
|
||||||
* The resulting entry is not exported to dependent projects. This method is equivalent to <code>newContainerEntry(path,false)</code>.
|
* The resulting entry is not exported to dependent projects. This method
|
||||||
|
* is equivalent to <code>newContainerEntry(path,false)</code>.
|
||||||
* <p>
|
* <p>
|
||||||
*/
|
*/
|
||||||
public static IContainerEntry newContainerEntry(String id, boolean isExported) {
|
public static IContainerEntry newContainerEntry(IPath id, boolean isExported) {
|
||||||
return new ContainerEntry(id, isExported);
|
return new ContainerEntry(id, isExported);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns a new non-exported entry of kind <code>CDT_LIBRARY</code> for the archive or folder identified by the
|
* Creates and returns a new non-exported entry of kind <code>CDT_LIBRARY</code>
|
||||||
* given absolute path.
|
* for the archive or folder identified by the given absolute path.
|
||||||
*
|
*
|
||||||
* Note that this operation does not attempt to validate or access the resources at the given paths.
|
* Note that this operation does not attempt to validate or access the
|
||||||
|
* resources at the given paths.
|
||||||
* <p>
|
* <p>
|
||||||
* The resulting entry is not exported to dependent projects. This method is equivalent to <code>newLibraryEntry(-,-,-,false)</code>.
|
* The resulting entry is not exported to dependent projects. This method
|
||||||
|
* is equivalent to <code>newLibraryEntry(-,-,-,false)</code>.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param path
|
* @param path
|
||||||
* the absolute path of the binary archive
|
* the absolute path of the binary archive
|
||||||
* @param sourceAttachmentPath
|
* @param sourceAttachmentPath
|
||||||
* the absolute path of the corresponding source archive or folder, or <code>null</code> if none.
|
* the absolute path of the corresponding source archive or
|
||||||
|
* folder, or <code>null</code> if none.
|
||||||
* @param sourceAttachmentRootPath
|
* @param sourceAttachmentRootPath
|
||||||
* the location of the root within the source archive or folder or <code>null</code>.
|
* the location of the root within the source archive or folder
|
||||||
|
* or <code>null</code>.
|
||||||
* @param sourceAttachmentPrefixMapping
|
* @param sourceAttachmentPrefixMapping
|
||||||
* prefix mapping or <code>null</code>.
|
* prefix mapping or <code>null</code>.
|
||||||
* @return a new library entry
|
* @return a new library entry
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static ILibraryEntry newLibraryEntry(
|
public static ILibraryEntry newLibraryEntry(IPath path, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath,
|
||||||
IPath path,
|
IPath sourceAttachmentPrefixMapping) {
|
||||||
IPath sourceAttachmentPath,
|
|
||||||
IPath sourceAttachmentRootPath,
|
|
||||||
IPath sourceAttachmentPrefixMapping) {
|
|
||||||
return newLibraryEntry(path, sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping, false);
|
return newLibraryEntry(path, sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns a new non-exported entry of kind <code>CDT_LIBRARY</code> for the archive or folder identified by the
|
* Creates and returns a new non-exported entry of kind <code>CDT_LIBRARY</code>
|
||||||
* given absolute path.
|
* for the archive or folder identified by the given absolute path.
|
||||||
*
|
*
|
||||||
* Note that this operation does not attempt to validate or access the resources at the given paths.
|
* Note that this operation does not attempt to validate or access the
|
||||||
|
* resources at the given paths.
|
||||||
* <p>
|
* <p>
|
||||||
*
|
*
|
||||||
* @param path
|
* @param path
|
||||||
* the absolute path of the binary archive
|
* the absolute path of the binary archive
|
||||||
* @param sourceAttachmentPath
|
* @param sourceAttachmentPath
|
||||||
* the absolute path of the corresponding source archive or folder, or <code>null</code> if none.
|
* the absolute path of the corresponding source archive or
|
||||||
|
* folder, or <code>null</code> if none.
|
||||||
* @param sourceAttachmentRootPath
|
* @param sourceAttachmentRootPath
|
||||||
* the location of the root within the source archive or folder or <code>null</code>.
|
* the location of the root within the source archive or folder
|
||||||
|
* or <code>null</code>.
|
||||||
* @param sourceAttachmentPrefixMapping
|
* @param sourceAttachmentPrefixMapping
|
||||||
* prefix mapping or <code>null</code>.
|
* prefix mapping or <code>null</code>.
|
||||||
* @return a new library entry
|
* @return a new library entry
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static ILibraryEntry newLibraryEntry(
|
public static ILibraryEntry newLibraryEntry(IPath path, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath,
|
||||||
IPath path,
|
IPath sourceAttachmentPrefixMapping, boolean isExported) {
|
||||||
IPath sourceAttachmentPath,
|
|
||||||
IPath sourceAttachmentRootPath,
|
|
||||||
IPath sourceAttachmentPrefixMapping,
|
|
||||||
boolean isExported) {
|
|
||||||
return new LibraryEntry(path, sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping, isExported);
|
return new LibraryEntry(path, sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping, isExported);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns a new entry of kind <code>CDT_SOURCE</code> for the project's source folder identified by the given
|
* Creates and returns a new entry of kind <code>CDT_SOURCE</code> for
|
||||||
* absolute workspace-relative path.
|
* the project's source folder identified by the given absolute
|
||||||
|
* workspace-relative path.
|
||||||
* <p>
|
* <p>
|
||||||
* The source folder is referred to using an absolute path relative to the workspace root, e.g. <code>/Project/src</code>. A
|
* The source folder is referred to using an absolute path relative to the
|
||||||
* project's source folders are located with that project. That is, a source entry specifying the path <code>/P1/src</code>
|
* workspace root, e.g. <code>/Project/src</code>. A project's source
|
||||||
* is only usable for project <code>P1</code>.
|
* folders are located with that project. That is, a source entry
|
||||||
|
* specifying the path <code>/P1/src</code> is only usable for project
|
||||||
|
* <code>P1</code>.
|
||||||
* </p>
|
* </p>
|
||||||
* </p>
|
* </p>
|
||||||
* <p>
|
* <p>
|
||||||
* Note that all sources/binaries inside a project are contributed as a whole through a project entry (see <code>newProjectEntry</code>).
|
* Note that all sources/binaries inside a project are contributed as a
|
||||||
|
* whole through a project entry (see <code>newProjectEntry</code>).
|
||||||
* Particular source entries cannot be selectively exported.
|
* Particular source entries cannot be selectively exported.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
|
@ -302,19 +321,24 @@ public class CoreModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns a new entry of kind <code>CDT_SOURCE</code> for the project's source folder identified by the given
|
* Creates and returns a new entry of kind <code>CDT_SOURCE</code> for
|
||||||
* absolute workspace-relative path but excluding all source files with paths matching any of the given patterns. This
|
* the project's source folder identified by the given absolute
|
||||||
* specifies that all package fragments within the root will have children of type <code>ICompilationUnit</code>.
|
* workspace-relative path but excluding all source files with paths
|
||||||
|
* matching any of the given patterns. This specifies that all package
|
||||||
|
* fragments within the root will have children of type <code>ICompilationUnit</code>.
|
||||||
* <p>
|
* <p>
|
||||||
* The source folder is referred to using an absolute path relative to the workspace root, e.g. <code>/Project/src</code>. A
|
* The source folder is referred to using an absolute path relative to the
|
||||||
* project's source folders are located with that project. That is, a source entry specifying the path <code>/P1/src</code>
|
* workspace root, e.g. <code>/Project/src</code>. A project's source
|
||||||
* is only usable for project <code>P1</code>.
|
* folders are located with that project. That is, a source entry
|
||||||
|
* specifying the path <code>/P1/src</code> is only usable for project
|
||||||
|
* <code>P1</code>.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path
|
* @param path
|
||||||
* the absolute workspace-relative path of a source folder
|
* the absolute workspace-relative path of a source folder
|
||||||
* @param exclusionPatterns
|
* @param exclusionPatterns
|
||||||
* the possibly empty list of exclusion patterns represented as relative paths
|
* the possibly empty list of exclusion patterns represented as
|
||||||
|
* relative paths
|
||||||
* @return a new source entry with the given exclusion patterns
|
* @return a new source entry with the given exclusion patterns
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -323,21 +347,27 @@ public class CoreModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns a new entry of kind <code>CDT_SOURCE</code> for the project's source folder identified by the given
|
* Creates and returns a new entry of kind <code>CDT_SOURCE</code> for
|
||||||
* absolute workspace-relative path but excluding all source files with paths matching any of the given patterns. This
|
* the project's source folder identified by the given absolute
|
||||||
* specifies that all package fragments within the root will have children of type <code>ICompilationUnit</code>.
|
* workspace-relative path but excluding all source files with paths
|
||||||
|
* matching any of the given patterns. This specifies that all package
|
||||||
|
* fragments within the root will have children of type <code>ICompilationUnit</code>.
|
||||||
* <p>
|
* <p>
|
||||||
* The source folder is referred to using an absolute path relative to the workspace root, e.g. <code>/Project/src</code>. A
|
* The source folder is referred to using an absolute path relative to the
|
||||||
* project's source folders are located with that project. That is, a source entry specifying the path <code>/P1/src</code>
|
* workspace root, e.g. <code>/Project/src</code>. A project's source
|
||||||
* is only usable for project <code>P1</code>.
|
* folders are located with that project. That is, a source entry
|
||||||
|
* specifying the path <code>/P1/src</code> is only usable for project
|
||||||
|
* <code>P1</code>.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path
|
* @param path
|
||||||
* the absolute workspace-relative path of a source folder
|
* the absolute workspace-relative path of a source folder
|
||||||
* @param exclusionPatterns
|
* @param exclusionPatterns
|
||||||
* the possibly empty list of exclusion patterns represented as relative paths
|
* the possibly empty list of exclusion patterns represented as
|
||||||
|
* relative paths
|
||||||
* @param specificOutputLocation
|
* @param specificOutputLocation
|
||||||
* the specific output location for this source entry (<code>null</code> if using project default ouput location)
|
* the specific output location for this source entry (<code>null</code>
|
||||||
|
* if using project default ouput location)
|
||||||
* @return a new source entry with the given exclusion patterns
|
* @return a new source entry with the given exclusion patterns
|
||||||
*/
|
*/
|
||||||
public static ISourceEntry newSourceEntry(IPath path, IPath outputLocation, IPath[] exclusionPatterns) {
|
public static ISourceEntry newSourceEntry(IPath path, IPath outputLocation, IPath[] exclusionPatterns) {
|
||||||
|
@ -345,21 +375,27 @@ public class CoreModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns a new entry of kind <code>CDT_SOURCE</code> for the project's source folder identified by the given
|
* Creates and returns a new entry of kind <code>CDT_SOURCE</code> for
|
||||||
* absolute workspace-relative path but excluding all source files with paths matching any of the given patterns. This
|
* the project's source folder identified by the given absolute
|
||||||
* specifies that all package fragments within the root will have children of type <code>ICompilationUnit</code>.
|
* workspace-relative path but excluding all source files with paths
|
||||||
|
* matching any of the given patterns. This specifies that all package
|
||||||
|
* fragments within the root will have children of type <code>ICompilationUnit</code>.
|
||||||
* <p>
|
* <p>
|
||||||
* The source folder is referred to using an absolute path relative to the workspace root, e.g. <code>/Project/src</code>. A
|
* The source folder is referred to using an absolute path relative to the
|
||||||
* project's source folders are located with that project. That is, a source entry specifying the path <code>/P1/src</code>
|
* workspace root, e.g. <code>/Project/src</code>. A project's source
|
||||||
* is only usable for project <code>P1</code>.
|
* folders are located with that project. That is, a source entry
|
||||||
|
* specifying the path <code>/P1/src</code> is only usable for project
|
||||||
|
* <code>P1</code>.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param path
|
* @param path
|
||||||
* the absolute workspace-relative path of a source folder
|
* the absolute workspace-relative path of a source folder
|
||||||
* @param exclusionPatterns
|
* @param exclusionPatterns
|
||||||
* the possibly empty list of exclusion patterns represented as relative paths
|
* the possibly empty list of exclusion patterns represented as
|
||||||
|
* relative paths
|
||||||
* @param specificOutputLocation
|
* @param specificOutputLocation
|
||||||
* the specific output location for this source entry (<code>null</code> if using project default ouput location)
|
* the specific output location for this source entry (<code>null</code>
|
||||||
|
* if using project default ouput location)
|
||||||
* @return a new source entry with the given exclusion patterns
|
* @return a new source entry with the given exclusion patterns
|
||||||
*/
|
*/
|
||||||
public static ISourceEntry newSourceEntry(IPath path, IPath outputLocation, boolean isRecursive, IPath[] exclusionPatterns) {
|
public static ISourceEntry newSourceEntry(IPath path, IPath outputLocation, boolean isRecursive, IPath[] exclusionPatterns) {
|
||||||
|
@ -370,10 +406,11 @@ public class CoreModel {
|
||||||
* Creates and returns a new entry of kind <code>CDT_INCLUDE</code>
|
* Creates and returns a new entry of kind <code>CDT_INCLUDE</code>
|
||||||
*
|
*
|
||||||
* @param path
|
* @param path
|
||||||
* the affected worksapce-relative resource path
|
* the affected worksapce-relative resource path, the path
|
||||||
|
* can pe empty or null if it is exported
|
||||||
* @param includePath
|
* @param includePath
|
||||||
* the absolute path of the include
|
* the absolute path of the include
|
||||||
* @return
|
* @return IIncludeEntry
|
||||||
*/
|
*/
|
||||||
public static IIncludeEntry newIncludeEntry(IPath path, IPath includePath) {
|
public static IIncludeEntry newIncludeEntry(IPath path, IPath includePath) {
|
||||||
return newIncludeEntry(path, includePath, false);
|
return newIncludeEntry(path, includePath, false);
|
||||||
|
@ -383,42 +420,39 @@ public class CoreModel {
|
||||||
* Creates and returns a new entry of kind <code>CDT_INCLUDE</code>
|
* Creates and returns a new entry of kind <code>CDT_INCLUDE</code>
|
||||||
*
|
*
|
||||||
* @param path
|
* @param path
|
||||||
* the affected workspace-relative resource path
|
* the affected workspace-relative resource path
|
||||||
|
* or the path can be empty or null if it is exported
|
||||||
* @param includePath
|
* @param includePath
|
||||||
* the absolute path of the include
|
* the absolute path of the include
|
||||||
* @param isSystemInclude
|
* @param isSystemInclude
|
||||||
* wheter this include path should be consider the system include path
|
* wheter this include path should be consider the system
|
||||||
* @return
|
* include path
|
||||||
|
* @return IIncludeEntry
|
||||||
*/
|
*/
|
||||||
public static IIncludeEntry newIncludeEntry(IPath path, IPath includePath, boolean isSystemInclude) {
|
public static IIncludeEntry newIncludeEntry(IPath path, IPath includePath, boolean isSystemInclude) {
|
||||||
return newIncludeEntry(path, includePath, isSystemInclude, true, IncludeEntry.NO_EXCLUSION_PATTERNS, true);
|
return newIncludeEntry(path, includePath, isSystemInclude, true, IncludeEntry.NO_EXCLUSION_PATTERNS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns a new entry of kind <code>CDT_INCLUDE</code>
|
* Creates and returns a new entry of kind <code>CDT_INCLUDE</code>
|
||||||
*
|
*
|
||||||
* @param path
|
* @param path
|
||||||
* the affected workspace-relative resource path
|
* the affected workspace-relative resource path or null if global
|
||||||
* @param includePath
|
* @param includePath
|
||||||
* the absolute path of the include
|
* the absolute path of the include
|
||||||
* @param isSystemInclude
|
* @param isSystemInclude
|
||||||
* wheter this include path should be consider the system include path
|
* wheter this include path should be consider the system
|
||||||
|
* include path
|
||||||
* @param isRecursive
|
* @param isRecursive
|
||||||
* if the resource is a folder the include applied to all recursively
|
* if the resource is a folder the include applied to all
|
||||||
|
* recursively
|
||||||
* @param exclusionPatterns
|
* @param exclusionPatterns
|
||||||
* exclusion patterns in the resource if a container
|
* exclusion patterns in the resource if a container
|
||||||
* @param isExported
|
* @return IIincludeEntry
|
||||||
* whether this cpath is exported.
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public static IIncludeEntry newIncludeEntry(
|
public static IIncludeEntry newIncludeEntry(IPath path, IPath includePath, boolean isSystemInclude, boolean isRecursive,
|
||||||
IPath path,
|
IPath[] exclusionPatterns) {
|
||||||
IPath includePath,
|
return new IncludeEntry(path, includePath, isSystemInclude, isRecursive, exclusionPatterns);
|
||||||
boolean isSystemInclude,
|
|
||||||
boolean isRecursive,
|
|
||||||
IPath[] exclusionPatterns,
|
|
||||||
boolean isExported) {
|
|
||||||
return new IncludeEntry(path, includePath, isSystemInclude, isRecursive, exclusionPatterns, isExported);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -446,38 +480,172 @@ public class CoreModel {
|
||||||
* @param macroValue
|
* @param macroValue
|
||||||
* the value of the macro
|
* the value of the macro
|
||||||
* @param isRecursive
|
* @param isRecursive
|
||||||
* if the resource is a folder the include applied to all recursively
|
* if the resource is a folder the include applied to all
|
||||||
|
* recursively
|
||||||
* @param exclusionPatterns
|
* @param exclusionPatterns
|
||||||
* exclusion patterns in the resource if a container
|
* exclusion patterns in the resource if a container
|
||||||
* @param isExported
|
* @param isExported
|
||||||
* whether this cpath is exported.
|
* whether this cpath is exported.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static IMacroEntry newMacroEntry(
|
public static IMacroEntry newMacroEntry(IPath path, String macroName, String macroValue, boolean isRecursive,
|
||||||
IPath path,
|
IPath[] exclusionPatterns, boolean isExported) {
|
||||||
String macroName,
|
|
||||||
String macroValue,
|
|
||||||
boolean isRecursive,
|
|
||||||
IPath[] exclusionPatterns,
|
|
||||||
boolean isExported) {
|
|
||||||
return new MacroEntry(path, macroName, macroValue, isRecursive, exclusionPatterns, isExported);
|
return new MacroEntry(path, macroName, macroValue, isRecursive, exclusionPatterns, isExported);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPathContainer getCPathContainer(IPath containerPath, ICProject project) throws CModelException {
|
/**
|
||||||
return manager.getCPathContainer(containerPath, project);
|
* Answers the project specific value for a given container. In case this
|
||||||
}
|
* container path could not be resolved, then will answer <code>null</code>.
|
||||||
|
* Both the container path and the project context are supposed to be
|
||||||
public void setCPathContainer(
|
* non-null.
|
||||||
IPath containerPath,
|
* <p>
|
||||||
ICProject[] affectedProjects,
|
* The containerPath is a formed by a first ID segment followed with extra
|
||||||
ICPathContainer[] respectiveContainers,
|
* segments, which can be used as additional hints for resolution. If no
|
||||||
IProgressMonitor monitor)
|
* container was ever recorded for this container path onto this project
|
||||||
throws CModelException {
|
* (using <code>setPathEntryContainer</code>, then a <code>PathEntryContainerInitializer</code>
|
||||||
manager.setCPatchContainer(containerPath, affectedProjects, respectiveContainers, monitor);
|
* will be activated if any was registered for this container ID onto the
|
||||||
|
* extension point "org.eclipse.cdt.core.PathEntryContainerInitializer".
|
||||||
|
* <p>
|
||||||
|
* PathEntry container values are persisted locally to the workspace, but
|
||||||
|
* are not preserved from a session to another. It is thus highly
|
||||||
|
* recommended to register a <code>PathEntryContainerInitializer</code>
|
||||||
|
* for each referenced container (through the extension point
|
||||||
|
* "org.eclipse.cdt.core.PathEntryContainerInitializer").
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @param containerPath
|
||||||
|
* the name of the container, which needs to be resolved
|
||||||
|
* @param project
|
||||||
|
* a specific project in which the container is being resolved
|
||||||
|
* @return the corresponding container or <code>null</code> if unable to
|
||||||
|
* find one.
|
||||||
|
*
|
||||||
|
* @exception CModelException
|
||||||
|
* if an exception occurred while resolving the container,
|
||||||
|
* or if the resolved container contains illegal entries
|
||||||
|
* (contains CDT_CONTAINER entries or null entries).
|
||||||
|
*
|
||||||
|
* @see PathEntryContainerInitializer
|
||||||
|
* @see IPathEntryContainer
|
||||||
|
* @see #setPathEntryContainer(IPath, ICProject[], IPathEntryContainer,
|
||||||
|
* IProgressMonitor)
|
||||||
|
*/
|
||||||
|
public IPathEntryContainer getPathEntryContainer(IPath containerPath, ICProject project) throws CModelException {
|
||||||
|
return pathEntryManager.getPathEntryContainer(containerPath, project);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: this is a temporary hack until, the CDescriptor manager is in place and could fire deltas of Parser change.
|
* Bind a container reference path to some actual containers (<code>IPathEntryContainer</code>).
|
||||||
|
* This API must be invoked whenever changes in container need to be
|
||||||
|
* reflected onto the CModel.
|
||||||
|
* <p>
|
||||||
|
* In reaction to changing container values, the CModel will be updated to
|
||||||
|
* reflect the new state of the updated container.
|
||||||
|
* <p>
|
||||||
|
* This functionality cannot be used while the resource tree is locked.
|
||||||
|
* <p>
|
||||||
|
* PathEntry container values are persisted locally to the workspace, but
|
||||||
|
* are not preserved from a session to another. It is thus highly
|
||||||
|
* recommended to register a <code>PathEntryContainerInitializer</code>
|
||||||
|
* for each referenced container (through the extension point
|
||||||
|
* "org.eclipse.cdt.core.PathEntryContainerInitializer").
|
||||||
|
* <p>
|
||||||
|
* Note: setting a container to <code>null</code> will cause it to be
|
||||||
|
* lazily resolved again whenever its value is required. In particular,
|
||||||
|
* this will cause a registered initializer to be invoked again.
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @param affectedProjects -
|
||||||
|
* the set of projects for which this container is being bound
|
||||||
|
* @param newContainer -
|
||||||
|
* the container for the affected projects
|
||||||
|
* @param monitor
|
||||||
|
* a monitor to report progress
|
||||||
|
* @throws CModelException
|
||||||
|
* @see PathEntryContainerInitializer
|
||||||
|
* @see #getPathEntryContainer(IPath, IJavaProject)
|
||||||
|
* @see IPathEntryContainer
|
||||||
|
*/
|
||||||
|
public void setPathEntryContainer(ICProject[] affectedProjects, IPathEntryContainer container, IProgressMonitor monitor)
|
||||||
|
throws CModelException {
|
||||||
|
pathEntryManager.setPathEntryContainer(affectedProjects, container, monitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the pathentries of this project using a list of entries.
|
||||||
|
* <p>
|
||||||
|
* Setting the pathentries to <code>null</code> specifies a default
|
||||||
|
* classpath (the project root). Setting the pathentry to an empty array
|
||||||
|
* specifies an empty pathentry.
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @param entries
|
||||||
|
* a list of entries
|
||||||
|
* @param monitor
|
||||||
|
* the given progress monitor
|
||||||
|
* @exception CModelException
|
||||||
|
* if the entries could not be set. Reasons include:
|
||||||
|
*/
|
||||||
|
public void setRawPathEntries(ICProject cproject, IPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException {
|
||||||
|
pathEntryManager.setRawPathEntries(cproject, newEntries, monitor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the raw pathentries for the project. This corresponds to the
|
||||||
|
* exact set of entries which were assigned using <code>setRawPathEntries</code>
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @return the raw entires for the project
|
||||||
|
* @exception CModelException
|
||||||
|
* if this element does not exist or if an exception occurs
|
||||||
|
* while accessing its corresponding resource
|
||||||
|
* @see IPathEntry
|
||||||
|
*/
|
||||||
|
public IPathEntry[] getRawPathEntries(ICProject cproject) throws CModelException {
|
||||||
|
return pathEntryManager.getRawPathEntries(cproject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returs the resolved pathentries for the project All
|
||||||
|
* pathEntry.CDT_CONTAINER entries in the project's will be replaced by the
|
||||||
|
* entries they resolve to.
|
||||||
|
* <p>
|
||||||
|
* The resulting resolved entries are accurate for the given point in time.
|
||||||
|
* If the project's raw entries are later modified they can become out of
|
||||||
|
* date. Because of this, hanging on resolved pathentries is not
|
||||||
|
* recommended.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @return the resolved entries for the project
|
||||||
|
* @exception CModelException
|
||||||
|
* @see IPathEntry
|
||||||
|
*/
|
||||||
|
public IPathEntry[] getResolvedClasspathEntries(ICProject cproject) throws CModelException {
|
||||||
|
return pathEntryManager.getRawPathEntries(cproject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method finding the pathentry container initializer registered for
|
||||||
|
* a given container ID or <code>null</code> if none was found while
|
||||||
|
* iterating over the contributions to extension point to the extension
|
||||||
|
* point "org.eclipse.cdt.core.PathEntryContainerInitializer".
|
||||||
|
* <p>
|
||||||
|
* A containerID is the first segment of any container path, used to
|
||||||
|
* identify the registered container initializer.
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @param containerID -
|
||||||
|
* a containerID identifying a registered initializer
|
||||||
|
* @return ClasspathContainerInitializer - the registered classpath
|
||||||
|
* container initializer or <code>null</code> if none was found.
|
||||||
|
*/
|
||||||
|
public static PathEntryContainerInitializer getPathEntryContainerInitializer(String containerID) {
|
||||||
|
return pathEntryManager.getPathEntryContainerInitializer(containerID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: this is a temporary hack until, the CDescriptor manager is in
|
||||||
|
* place and could fire deltas of Parser change.
|
||||||
*
|
*
|
||||||
* @deprecated this function will be removed shortly.
|
* @deprecated this function will be removed shortly.
|
||||||
*/
|
*/
|
||||||
|
@ -492,6 +660,7 @@ public class CoreModel {
|
||||||
if (cmodel == null) {
|
if (cmodel == null) {
|
||||||
cmodel = new CoreModel();
|
cmodel = new CoreModel();
|
||||||
manager = CModelManager.getDefault();
|
manager = CModelManager.getDefault();
|
||||||
|
pathEntryManager = PathEntryManager.getDefault();
|
||||||
}
|
}
|
||||||
return cmodel;
|
return cmodel;
|
||||||
}
|
}
|
||||||
|
@ -501,7 +670,8 @@ public class CoreModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the given element changed listener. Has no affect if an identical listener is not registered.
|
* Removes the given element changed listener. Has no affect if an
|
||||||
|
* identical listener is not registered.
|
||||||
*
|
*
|
||||||
* @param listener
|
* @param listener
|
||||||
* the listener
|
* the listener
|
||||||
|
@ -529,7 +699,8 @@ public class CoreModel {
|
||||||
if (workspace.isTreeLocked()) {
|
if (workspace.isTreeLocked()) {
|
||||||
new BatchOperation(action).run(monitor);
|
new BatchOperation(action).run(monitor);
|
||||||
} else {
|
} else {
|
||||||
// use IWorkspace.run(...) to ensure that a build will be done in autobuild mode
|
// use IWorkspace.run(...) to ensure that a build will be done in
|
||||||
|
// autobuild mode
|
||||||
workspace.run(new BatchOperation(action), monitor);
|
workspace.run(new BatchOperation(action), monitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
/**********************************************************************
|
|
||||||
* Created on Mar 25, 2003
|
|
||||||
*
|
|
||||||
* Copyright (c) 2002,2003 QNX Software Systems Ltd. and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v0.5
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v05.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* QNX Software Systems - Initial API and implementation
|
|
||||||
***********************************************************************/
|
|
||||||
|
|
||||||
package org.eclipse.cdt.core.model;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author alain
|
|
||||||
*/
|
|
||||||
public interface ICPathContainer {
|
|
||||||
|
|
||||||
ICPathEntry[] getCPathEntries();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Answers a readable description of this container
|
|
||||||
*
|
|
||||||
* @return String - a string description of the container
|
|
||||||
*/
|
|
||||||
String getDescription();
|
|
||||||
|
|
||||||
}
|
|
|
@ -131,7 +131,7 @@ public interface ICProject extends ICContainer {
|
||||||
* @exception CModelException if this element does not exist or if an
|
* @exception CModelException if this element does not exist or if an
|
||||||
* exception occurs while accessing its corresponding resource
|
* exception occurs while accessing its corresponding resource
|
||||||
*/
|
*/
|
||||||
ICPathEntry[] getResolvedCPathEntries() throws CModelException;
|
IPathEntry[] getResolvedPathEntries() throws CModelException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of entries for the project. This corresponds to the exact set
|
* Returns the list of entries for the project. This corresponds to the exact set
|
||||||
|
@ -142,12 +142,12 @@ public interface ICProject extends ICContainer {
|
||||||
* @exception CModelException if this element does not exist or if an
|
* @exception CModelException if this element does not exist or if an
|
||||||
* exception occurs while accessing its corresponding resource
|
* exception occurs while accessing its corresponding resource
|
||||||
*/
|
*/
|
||||||
ICPathEntry[] getRawCPathEntries() throws CModelException;
|
IPathEntry[] getRawPathEntries() throws CModelException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the entries for this project.
|
* Sets the entries for this project.
|
||||||
*
|
*
|
||||||
* @param entries a list of ICPathEntry[] entries
|
* @param entries a list of IPathEntry[] entries
|
||||||
* @param monitor the given progress monitor
|
* @param monitor the given progress monitor
|
||||||
* @exception CModelException if the entries could not be set. Reasons include:
|
* @exception CModelException if the entries could not be set. Reasons include:
|
||||||
* <ul>
|
* <ul>
|
||||||
|
@ -155,6 +155,6 @@ public interface ICProject extends ICContainer {
|
||||||
* <li> The entries are being modified during resource change event notification (CORE_EXCEPTION)
|
* <li> The entries are being modified during resource change event notification (CORE_EXCEPTION)
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
void setRawCPathEntries(ICPathEntry[] entries, IProgressMonitor monitor) throws CModelException;
|
void setRawPathEntries(IPathEntry[] entries, IProgressMonitor monitor) throws CModelException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,12 +12,14 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.core.model;
|
package org.eclipse.cdt.core.model;
|
||||||
|
|
||||||
public interface IContainerEntry extends ICPathEntry {
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
|
public interface IContainerEntry extends IPathEntry {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the id identifying this container.
|
* Returns the id identifying this container.
|
||||||
* @return String
|
* @return IPath
|
||||||
*/
|
*/
|
||||||
String getId();
|
IPath getPath();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ package org.eclipse.cdt.core.model;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public interface IIncludeEntry extends ICPathEntry {
|
public interface IIncludeEntry extends IPathEntry {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the affected resource by the include.
|
* Returns the affected resource by the include.
|
||||||
|
|
|
@ -14,7 +14,7 @@ package org.eclipse.cdt.core.model;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public interface ILibraryEntry extends ICPathEntry {
|
public interface ILibraryEntry extends IPathEntry {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the absolute path of the library
|
* Returns the absolute path of the library
|
||||||
|
|
|
@ -14,7 +14,7 @@ package org.eclipse.cdt.core.model;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public interface IMacroEntry extends ICPathEntry {
|
public interface IMacroEntry extends IPathEntry {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the absolute path from the worskspace root or
|
* Returns the absolute path from the worskspace root or
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
package org.eclipse.cdt.core.model;
|
package org.eclipse.cdt.core.model;
|
||||||
|
|
||||||
|
|
||||||
public interface ICPathEntry {
|
public interface IPathEntry {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Entry kind constant describing a path entry identifying a
|
* Entry kind constant describing a path entry identifying a
|
|
@ -0,0 +1,60 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Created on Mar 25, 2003
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002,2003 QNX Software Systems Ltd. and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.core.model;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author alain
|
||||||
|
*/
|
||||||
|
public interface IPathEntryContainer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Answers the set of path entries this container is mapping to.
|
||||||
|
* <p>
|
||||||
|
* The set of entries associated with a container may contain any of the following:
|
||||||
|
* <ul>
|
||||||
|
* <li> library entries (<code>CDT_LIBRARY</code>) </li>
|
||||||
|
* <li> project entries (<code>CDT_PROJECT</code>) </li>
|
||||||
|
* <li> macro entries (<code>CDT_MACRO</code>) </li>
|
||||||
|
* <li> include entries (<code>CDT_INCLUDE</code>) </li>
|
||||||
|
* </ul>
|
||||||
|
* A container can neither reference further containers.
|
||||||
|
*
|
||||||
|
* @return IPathEntry[] - the entries this container represents
|
||||||
|
* @see IPathEntry
|
||||||
|
*/
|
||||||
|
IPathEntry[] getPathEntries();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Answers a readable description of this container
|
||||||
|
*
|
||||||
|
* @return String - a string description of the container
|
||||||
|
*/
|
||||||
|
String getDescription();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Answers the container path identifying this container.
|
||||||
|
* A container path is formed by a first ID segment followed with extra segments, which
|
||||||
|
* can be used as additional hints for resolving to this container.
|
||||||
|
* <p>
|
||||||
|
* The container ID is also used to identify a<code>ClasspathContainerInitializer</code>
|
||||||
|
* registered on the extension point "org.eclipse.jdt.core.classpathContainerInitializer", which can
|
||||||
|
* be invoked if needing to resolve the container before it is explicitly set.
|
||||||
|
* <p>
|
||||||
|
* @return IPath - the container path that is associated with this container
|
||||||
|
*/
|
||||||
|
IPath getPath();
|
||||||
|
|
||||||
|
}
|
|
@ -15,7 +15,7 @@ package org.eclipse.cdt.core.model;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
|
|
||||||
public interface IProjectEntry extends ICPathEntry {
|
public interface IProjectEntry extends IPathEntry {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the absolute path relative to the workspace root.
|
* Returns the absolute path relative to the workspace root.
|
||||||
|
|
|
@ -14,7 +14,7 @@ package org.eclipse.cdt.core.model;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public interface ISourceEntry extends ICPathEntry {
|
public interface ISourceEntry extends IPathEntry {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the absolute path from the worskspace root or
|
* Returns the absolute path from the worskspace root or
|
||||||
|
|
|
@ -18,12 +18,12 @@ import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public abstract class CPathContainerInitializer {
|
public abstract class PathEntryContainerInitializer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new cpath container initializer.
|
* Creates a new cpath container initializer.
|
||||||
*/
|
*/
|
||||||
public CPathContainerInitializer() {
|
public PathEntryContainerInitializer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void initialize(IPath containerPath, ICProject project) throws CoreException;
|
public abstract void initialize(IPath containerPath, ICProject project) throws CoreException;
|
|
@ -14,13 +14,13 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public abstract class ACPathEntry extends CPathEntry {
|
public abstract class APathEntry extends PathEntry {
|
||||||
|
|
||||||
public static IPath[] NO_EXCLUSION_PATTERNS = {};
|
public static IPath[] NO_EXCLUSION_PATTERNS = {};
|
||||||
IPath[] exclusionPatterns;
|
IPath[] exclusionPatterns;
|
||||||
boolean isRecursive;
|
boolean isRecursive;
|
||||||
|
|
||||||
public ACPathEntry (int kind, boolean isRecursive, IPath[] exclusionPatterns, boolean isExported) {
|
public APathEntry (int kind, boolean isRecursive, IPath[] exclusionPatterns, boolean isExported) {
|
||||||
super(kind, isExported);
|
super(kind, isExported);
|
||||||
this.exclusionPatterns = exclusionPatterns;
|
this.exclusionPatterns = exclusionPatterns;
|
||||||
this.isRecursive = isRecursive;
|
this.isRecursive = isRecursive;
|
||||||
|
@ -43,8 +43,8 @@ public abstract class ACPathEntry extends CPathEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj instanceof ACPathEntry) {
|
if (obj instanceof APathEntry) {
|
||||||
ACPathEntry otherEntry = (ACPathEntry)obj;
|
APathEntry otherEntry = (APathEntry)obj;
|
||||||
if (!super.equals(otherEntry)) {
|
if (!super.equals(otherEntry)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
|
@ -27,7 +27,6 @@ import org.eclipse.cdt.core.model.ICContainer;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
import org.eclipse.cdt.core.model.ICModel;
|
import org.eclipse.cdt.core.model.ICModel;
|
||||||
import org.eclipse.cdt.core.model.ICPathContainer;
|
|
||||||
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.IParent;
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
|
@ -50,12 +49,12 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
|
||||||
public class CModelManager implements IResourceChangeListener {
|
public class CModelManager implements IResourceChangeListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unique handle onto the CModel
|
* Unique handle onto the CModel
|
||||||
*/
|
*/
|
||||||
final CModel cModel = new CModel();
|
final CModel cModel = new CModel();
|
||||||
|
|
||||||
public static HashSet OptionNames = new HashSet(20);
|
public static HashSet OptionNames = new HashSet(20);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to convert <code>IResourceDelta</code>s into <code>ICElementDelta</code>s.
|
* Used to convert <code>IResourceDelta</code>s into <code>ICElementDelta</code>s.
|
||||||
|
@ -112,10 +111,11 @@ public class CModelManager implements IResourceChangeListener {
|
||||||
*/
|
*/
|
||||||
private HashMap sourceMappers = new HashMap();
|
private HashMap sourceMappers = new HashMap();
|
||||||
|
|
||||||
|
// TODO: This should be in a preference/property page
|
||||||
public static final String [] sourceExtensions = {"c", "cxx", "cc", "C", "cpp"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
public static final String [] sourceExtensions = {"c", "cxx", "cc", "C", "cpp"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
||||||
|
|
||||||
public static final String [] headerExtensions = {"h", "hh", "hpp", "H"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
public static final String [] headerExtensions = {"h", "hh", "hpp", "H"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
|
public static final String [] assemblyExtensions = {"s", "S"}; //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
|
|
||||||
public static final IWorkingCopy[] NoWorkingCopy = new IWorkingCopy[0];
|
public static final IWorkingCopy[] NoWorkingCopy = new IWorkingCopy[0];
|
||||||
|
|
||||||
static CModelManager factory = null;
|
static CModelManager factory = null;
|
||||||
|
@ -447,61 +447,53 @@ public class CModelManager implements IResourceChangeListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSharedLib(IFile file) {
|
public boolean isSharedLib(IFile file) {
|
||||||
try {
|
ICElement celement = create(file);
|
||||||
IBinaryParser parser = getBinaryParser(file.getProject());
|
if (celement instanceof IBinary) {
|
||||||
IBinaryFile bin = parser.getBinary(file.getLocation());
|
return ((IBinary)celement).isSharedLib();
|
||||||
return (bin.getType() == IBinaryFile.SHARED);
|
|
||||||
} catch (IOException e) {
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isObject(IFile file) {
|
public boolean isObject(IFile file) {
|
||||||
try {
|
ICElement celement = create(file);
|
||||||
IBinaryParser parser = getBinaryParser(file.getProject());
|
if (celement instanceof IBinary) {
|
||||||
IBinaryFile bin = parser.getBinary(file.getLocation());
|
return ((IBinary)celement).isObject();
|
||||||
return (bin.getType() == IBinaryFile.OBJECT);
|
|
||||||
} catch (IOException e) {
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isExecutable(IFile file) {
|
public boolean isExecutable(IFile file) {
|
||||||
try {
|
ICElement celement = create(file);
|
||||||
IBinaryParser parser = getBinaryParser(file.getProject());
|
if (celement instanceof IBinary) {
|
||||||
IBinaryFile bin = parser.getBinary(file.getLocation());
|
return ((IBinary)celement).isExecutable();
|
||||||
return (bin.getType() == IBinaryFile.EXECUTABLE);
|
|
||||||
} catch (IOException e) {
|
|
||||||
//e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBinary(IFile file) {
|
public boolean isBinary(IFile file) {
|
||||||
try {
|
ICElement celement = create(file);
|
||||||
IBinaryParser parser = getBinaryParser(file.getProject());
|
return (celement instanceof IBinary);
|
||||||
IBinaryFile bin = parser.getBinary(file.getLocation());
|
|
||||||
return (bin.getType() == IBinaryFile.EXECUTABLE
|
|
||||||
|| bin.getType() == IBinaryFile.OBJECT
|
|
||||||
|| bin.getType() == IBinaryFile.SHARED
|
|
||||||
|| bin.getType() == IBinaryFile.CORE);
|
|
||||||
} catch (IOException e) {
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isArchive(IFile file) {
|
public boolean isArchive(IFile file) {
|
||||||
try {
|
ICElement celement = create(file);
|
||||||
IBinaryParser parser = getBinaryParser(file.getProject());
|
return(celement instanceof IArchive);
|
||||||
IBinaryFile bin = parser.getBinary(file.getLocation());
|
|
||||||
return (bin.getType() == IBinaryFile.ARCHIVE);
|
|
||||||
} catch (IOException e) {
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTranslationUnit(IFile file) {
|
public boolean isTranslationUnit(IFile file) {
|
||||||
return isValidTranslationUnitName(file.getName());
|
return file != null && isValidTranslationUnitName(file.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSourceUnit(IFile file) {
|
||||||
|
return file != null && isValidSourceUnitName(file.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHeaderUnit(IFile file) {
|
||||||
|
return file != null && isValidHeaderUnitName(file.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAssemblyUnit(IFile file) {
|
||||||
|
return file != null && isValidAssemblyUnitName(file.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValidTranslationUnitName(String name){
|
public boolean isValidTranslationUnitName(String name){
|
||||||
|
@ -513,7 +505,7 @@ public class CModelManager implements IResourceChangeListener {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String ext = name.substring(index + 1);
|
String ext = name.substring(index + 1);
|
||||||
String[] cexts = getTranslationUnitExtensions();
|
String[] cexts = getHeaderExtensions();
|
||||||
for (int i = 0; i < cexts.length; i++) {
|
for (int i = 0; i < cexts.length; i++) {
|
||||||
if (ext.equals(cexts[i]))
|
if (ext.equals(cexts[i]))
|
||||||
return true;
|
return true;
|
||||||
|
@ -521,6 +513,57 @@ public class CModelManager implements IResourceChangeListener {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isValidSourceUnitName(String name){
|
||||||
|
if (name == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int index = name.lastIndexOf('.');
|
||||||
|
if (index == -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String ext = name.substring(index + 1);
|
||||||
|
String[] cexts = getSourceExtensions();
|
||||||
|
for (int i = 0; i < cexts.length; i++) {
|
||||||
|
if (ext.equals(cexts[i]))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValidHeaderUnitName(String name){
|
||||||
|
if (name == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int index = name.lastIndexOf('.');
|
||||||
|
if (index == -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String ext = name.substring(index + 1);
|
||||||
|
String[] cexts = getHeaderExtensions();
|
||||||
|
for (int i = 0; i < cexts.length; i++) {
|
||||||
|
if (ext.equals(cexts[i]))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValidAssemblyUnitName(String name){
|
||||||
|
if (name == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int index = name.lastIndexOf('.');
|
||||||
|
if (index == -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String ext = name.substring(index + 1);
|
||||||
|
String[] cexts = getAssemblyExtensions();
|
||||||
|
for (int i = 0; i < cexts.length; i++) {
|
||||||
|
if (ext.equals(cexts[i]))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public String[] getHeaderExtensions() {
|
public String[] getHeaderExtensions() {
|
||||||
return headerExtensions;
|
return headerExtensions;
|
||||||
}
|
}
|
||||||
|
@ -529,12 +572,18 @@ public class CModelManager implements IResourceChangeListener {
|
||||||
return sourceExtensions;
|
return sourceExtensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String[] getAssemblyExtensions() {
|
||||||
|
return assemblyExtensions;
|
||||||
|
}
|
||||||
|
|
||||||
public String[] getTranslationUnitExtensions() {
|
public String[] getTranslationUnitExtensions() {
|
||||||
String[] headers = getHeaderExtensions();
|
|
||||||
String[] sources = getSourceExtensions();
|
String[] sources = getSourceExtensions();
|
||||||
String[] cexts = new String[headers.length + sources.length];
|
String[] headers = getHeaderExtensions();
|
||||||
|
String[] asm = getAssemblyExtensions();
|
||||||
|
String[] cexts = new String[headers.length + sources.length + asm.length];
|
||||||
System.arraycopy(sources, 0, cexts, 0, sources.length);
|
System.arraycopy(sources, 0, cexts, 0, sources.length);
|
||||||
System.arraycopy(headers, 0, cexts, sources.length, headers.length);
|
System.arraycopy(headers, 0, cexts, sources.length, headers.length);
|
||||||
|
System.arraycopy(asm, 0, cexts, sources.length + headers.length, asm.length);
|
||||||
return cexts;
|
return cexts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -886,25 +935,4 @@ public class CModelManager implements IResourceChangeListener {
|
||||||
this.getIndexManager().discardJobs(project.getName());
|
this.getIndexManager().discardJobs(project.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param containerPath
|
|
||||||
* @param project
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public ICPathContainer getCPathContainer(IPath containerPath, ICProject project) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param containerPath
|
|
||||||
* @param affectedProjects
|
|
||||||
* @param respectiveContainers
|
|
||||||
* @param monitor
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Object setCPatchContainer(IPath containerPath, ICProject[] affectedProjects, ICPathContainer[] respectiveContainers, IProgressMonitor monitor) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import java.util.Map;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.CProjectNature;
|
import org.eclipse.cdt.core.CProjectNature;
|
||||||
import org.eclipse.cdt.core.IBinaryParser;
|
import org.eclipse.cdt.core.IBinaryParser;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryArchive;
|
||||||
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
@ -23,37 +22,20 @@ import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.IArchiveContainer;
|
import org.eclipse.cdt.core.model.IArchiveContainer;
|
||||||
import org.eclipse.cdt.core.model.IBinaryContainer;
|
import org.eclipse.cdt.core.model.IBinaryContainer;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICModelStatus;
|
|
||||||
import org.eclipse.cdt.core.model.ICModelStatusConstants;
|
import org.eclipse.cdt.core.model.ICModelStatusConstants;
|
||||||
import org.eclipse.cdt.core.model.ICPathEntry;
|
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IContainerEntry;
|
|
||||||
import org.eclipse.cdt.core.model.IIncludeEntry;
|
|
||||||
import org.eclipse.cdt.core.model.ILibraryEntry;
|
import org.eclipse.cdt.core.model.ILibraryEntry;
|
||||||
import org.eclipse.cdt.core.model.ILibraryReference;
|
import org.eclipse.cdt.core.model.ILibraryReference;
|
||||||
import org.eclipse.cdt.core.model.IMacroEntry;
|
import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
import org.eclipse.cdt.core.model.IProjectEntry;
|
|
||||||
import org.eclipse.cdt.core.model.ISourceEntry;
|
|
||||||
import org.eclipse.cdt.internal.core.CharOperation;
|
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
import org.eclipse.core.runtime.Preferences;
|
import org.eclipse.core.runtime.Preferences;
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
import org.eclipse.core.runtime.QualifiedName;
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
import org.w3c.dom.NodeList;
|
|
||||||
|
|
||||||
public class CProject extends CContainer implements ICProject {
|
public class CProject extends CContainer implements ICProject {
|
||||||
|
|
||||||
/**
|
|
||||||
* An empty array of strings indicating that a project doesn't have any prerequesite projects.
|
|
||||||
*/
|
|
||||||
protected static final String[] NO_PREREQUISITES = new String[0];
|
|
||||||
|
|
||||||
public CProject(ICElement parent, IProject project) {
|
public CProject(ICElement parent, IProject project) {
|
||||||
super(parent, project, CElement.C_PROJECT);
|
super(parent, project, CElement.C_PROJECT);
|
||||||
}
|
}
|
||||||
|
@ -115,9 +97,9 @@ public class CProject extends CContainer implements ICProject {
|
||||||
binParser = CCorePlugin.getDefault().getBinaryParser(getProject());
|
binParser = CCorePlugin.getDefault().getBinaryParser(getProject());
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
ICPathEntry[] entries = getResolvedCPathEntries();
|
IPathEntry[] entries = getResolvedPathEntries();
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (int i = 0; i < entries.length; i++) {
|
||||||
if (entries[i].getEntryKind() == ICPathEntry.CDT_LIBRARY) {
|
if (entries[i].getEntryKind() == IPathEntry.CDT_LIBRARY) {
|
||||||
ILibraryEntry entry = (ILibraryEntry) entries[i];
|
ILibraryEntry entry = (ILibraryEntry) entries[i];
|
||||||
ILibraryReference lib = null;
|
ILibraryReference lib = null;
|
||||||
if (binParser != null) {
|
if (binParser != null) {
|
||||||
|
@ -145,28 +127,14 @@ public class CProject extends CContainer implements ICProject {
|
||||||
* @see ICProject#getRequiredProjectNames()
|
* @see ICProject#getRequiredProjectNames()
|
||||||
*/
|
*/
|
||||||
public String[] getRequiredProjectNames() throws CModelException {
|
public String[] getRequiredProjectNames() throws CModelException {
|
||||||
return projectPrerequisites(getResolvedCPathEntries());
|
return projectPrerequisites(getResolvedPathEntries());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] projectPrerequisites(ICPathEntry[] entries) throws CModelException {
|
public String[] projectPrerequisites(IPathEntry[] entries) throws CModelException {
|
||||||
ArrayList prerequisites = new ArrayList();
|
return PathEntryManager.getDefault().projectPrerequisites(entries);
|
||||||
for (int i = 0, length = entries.length; i < length; i++) {
|
|
||||||
if (entries[i].getEntryKind() == ICPathEntry.CDT_PROJECT) {
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
return NO_PREREQUISITES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.core.model.ICProject#getOption(String, boolean)
|
* @see org.eclipse.cdt.core.model.ICProject#getOption(String, boolean)
|
||||||
*/
|
*/
|
||||||
|
@ -316,264 +284,25 @@ public class CProject extends CContainer implements ICProject {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static String PATH_ENTRY = "cpathentry"; //$NON-NLS-1$
|
|
||||||
static String PATH_ENTRY_ID = "org.eclipse.cdt.core.cpathentry"; //$NON-NLS-1$
|
|
||||||
static String ATTRIBUTE_KIND = "kind"; //$NON-NLS-1$
|
|
||||||
static String ATTRIBUTE_PATH = "path"; //$NON-NLS-1$
|
|
||||||
static String ATTRIBUTE_EXPORTED = "exported"; //$NON-NLS-1$
|
|
||||||
static String ATTRIBUTE_SOURCEPATH = "sourcepath"; //$NON-NLS-1$
|
|
||||||
static String ATTRIBUTE_ROOTPATH = "roopath"; //$NON-NLS-1$
|
|
||||||
static String ATTRIBUTE_PREFIXMAPPING = "prefixmapping"; //$NON-NLS-1$
|
|
||||||
static String ATTRIBUTE_EXCLUDING = "excluding"; //$NON-NLS-1$
|
|
||||||
static String ATTRIBUTE_RECUSIVE = "recusive"; //$NON-NLS-1$
|
|
||||||
static String ATTRIBUTE_OUTPUT = "output"; //$NON-NLS-1$
|
|
||||||
static String ATTRIBUTE_INCLUDE = "include"; //$NON-NLS-1$
|
|
||||||
static String ATTRIBUTE_SYSTEM = "system"; //$NON-NLS-1$
|
|
||||||
static String ATTRIBUTE_NAME = "name"; //$NON-NLS-1$
|
|
||||||
static String ATTRIBUTE_VALUE = "value"; //$NON-NLS-1$
|
|
||||||
static String ATTRIBUTE_ID = "id"; //$NON-NLS-1$
|
|
||||||
static String VALUE_TRUE = "true"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.model.ICProject#getResolvedCPathEntries()
|
* @see org.eclipse.cdt.core.model.ICProject#getResolvedCPathEntries()
|
||||||
*/
|
*/
|
||||||
public ICPathEntry[] getResolvedCPathEntries() throws CModelException {
|
public IPathEntry[] getResolvedPathEntries() throws CModelException {
|
||||||
// Not implemented
|
return CoreModel.getDefault().getResolvedClasspathEntries(this);
|
||||||
return getRawCPathEntries();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.model.ICProject#getRawCPathEntries()
|
* @see org.eclipse.cdt.core.model.ICProject#getRawCPathEntries()
|
||||||
*/
|
*/
|
||||||
public ICPathEntry[] getRawCPathEntries() throws CModelException {
|
public IPathEntry[] getRawPathEntries() throws CModelException {
|
||||||
ArrayList pathEntries = new ArrayList();
|
return CoreModel.getDefault().getRawPathEntries(this);
|
||||||
try {
|
|
||||||
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(getProject());
|
|
||||||
Element element = cdesc.getProjectData(PATH_ENTRY_ID);
|
|
||||||
NodeList list = element.getChildNodes();
|
|
||||||
for (int i = 0; i < list.getLength(); i++) {
|
|
||||||
Node childNode = list.item(i);
|
|
||||||
if (childNode.getNodeType() == Node.ELEMENT_NODE) {
|
|
||||||
if (childNode.getNodeName().equals(PATH_ENTRY)) {
|
|
||||||
pathEntries.add(decodeCPathEntry((Element) childNode));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
throw new CModelException(e);
|
|
||||||
}
|
|
||||||
return (ICPathEntry[]) pathEntries.toArray(new ICPathEntry[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.model.ICProject#setRawCPathEntries(org.eclipse.cdt.core.model.ICPathEntry[], org.eclipse.core.runtime.IProgressMonitor)
|
* @see org.eclipse.cdt.core.model.ICProject#setRawCPathEntries(org.eclipse.cdt.core.model.IPathEntry[], org.eclipse.core.runtime.IProgressMonitor)
|
||||||
*/
|
*/
|
||||||
public void setRawCPathEntries(ICPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException {
|
public void setRawPathEntries(IPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException {
|
||||||
try {
|
CoreModel.getDefault().setRawPathEntries(this, newEntries, monitor);
|
||||||
SetCPathEntriesOperation op = new SetCPathEntriesOperation(this, getRawCPathEntries(), newEntries);
|
|
||||||
runOperation(op, monitor);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
throw new CModelException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ICPathEntry decodeCPathEntry(Element element) throws CModelException {
|
|
||||||
IPath projectPath = getProject().getFullPath();
|
|
||||||
|
|
||||||
// kind
|
|
||||||
String kindAttr = element.getAttribute(ATTRIBUTE_KIND);
|
|
||||||
int kind = CPathEntry.kindFromString(kindAttr);
|
|
||||||
|
|
||||||
// exported flag
|
|
||||||
boolean isExported = false;
|
|
||||||
if (element.hasAttribute(ATTRIBUTE_EXPORTED)) {
|
|
||||||
isExported = element.getAttribute(ATTRIBUTE_EXPORTED).equals(VALUE_TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ensure path is absolute
|
|
||||||
String pathAttr = element.getAttribute(ATTRIBUTE_PATH);
|
|
||||||
IPath path = new Path(pathAttr);
|
|
||||||
if (kind != ICPathEntry.CDT_VARIABLE && !path.isAbsolute()) {
|
|
||||||
path = projectPath.append(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
// source attachment info (optional)
|
|
||||||
IPath sourceAttachmentPath =
|
|
||||||
element.hasAttribute(ATTRIBUTE_SOURCEPATH) ? new Path(element.getAttribute(ATTRIBUTE_SOURCEPATH)) : null;
|
|
||||||
IPath sourceAttachmentRootPath =
|
|
||||||
element.hasAttribute(ATTRIBUTE_ROOTPATH) ? new Path(element.getAttribute(ATTRIBUTE_ROOTPATH)) : null;
|
|
||||||
IPath sourceAttachmentPrefixMapping =
|
|
||||||
element.hasAttribute(ATTRIBUTE_PREFIXMAPPING) ? new Path(element.getAttribute(ATTRIBUTE_PREFIXMAPPING)) : null;
|
|
||||||
|
|
||||||
// exclusion patterns (optional)
|
|
||||||
String exclusion = element.getAttribute(ATTRIBUTE_EXCLUDING);
|
|
||||||
IPath[] exclusionPatterns = ACPathEntry.NO_EXCLUSION_PATTERNS;
|
|
||||||
if (!exclusion.equals("")) { //$NON-NLS-1$
|
|
||||||
char[][] patterns = CharOperation.splitOn('|', exclusion.toCharArray());
|
|
||||||
int patternCount;
|
|
||||||
if ((patternCount = patterns.length) > 0) {
|
|
||||||
exclusionPatterns = new IPath[patternCount];
|
|
||||||
for (int j = 0; j < patterns.length; j++) {
|
|
||||||
exclusionPatterns[j] = new Path(new String(patterns[j]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean isRecursive = false;
|
|
||||||
if (element.hasAttribute(ATTRIBUTE_RECUSIVE)) {
|
|
||||||
isRecursive = element.getAttribute(ATTRIBUTE_RECUSIVE).equals(VALUE_TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// recreate the CP entry
|
|
||||||
|
|
||||||
switch (kind) {
|
|
||||||
|
|
||||||
case ICPathEntry.CDT_PROJECT :
|
|
||||||
return CoreModel.newProjectEntry(path, isExported);
|
|
||||||
|
|
||||||
case ICPathEntry.CDT_LIBRARY :
|
|
||||||
return CoreModel.newLibraryEntry(
|
|
||||||
path,
|
|
||||||
sourceAttachmentPath,
|
|
||||||
sourceAttachmentRootPath,
|
|
||||||
sourceAttachmentPrefixMapping,
|
|
||||||
isExported);
|
|
||||||
|
|
||||||
case ICPathEntry.CDT_SOURCE :
|
|
||||||
{
|
|
||||||
// custom output location
|
|
||||||
IPath outputLocation = element.hasAttribute(ATTRIBUTE_OUTPUT) ? projectPath.append(element.getAttribute(ATTRIBUTE_OUTPUT)) : null; //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
// must be an entry in this project or specify another project
|
|
||||||
String projSegment = path.segment(0);
|
|
||||||
if (projSegment != null && projSegment.equals(getElementName())) { // this project
|
|
||||||
return CoreModel.newSourceEntry(path, outputLocation, isRecursive, exclusionPatterns);
|
|
||||||
} else { // another project
|
|
||||||
return CoreModel.newProjectEntry(path, isExported);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// case ICPathEntry.CDT_VARIABLE :
|
|
||||||
// return CoreModel.newVariableEntry(path, sourceAttachmentPath, sourceAttachmentRootPath);
|
|
||||||
|
|
||||||
case ICPathEntry.CDT_INCLUDE :
|
|
||||||
{
|
|
||||||
// include path info (optional
|
|
||||||
IPath includePath =
|
|
||||||
element.hasAttribute(ATTRIBUTE_INCLUDE) ? new Path(element.getAttribute(ATTRIBUTE_INCLUDE)) : null;
|
|
||||||
// isSysteminclude
|
|
||||||
boolean isSystemInclude = false;
|
|
||||||
if (element.hasAttribute(ATTRIBUTE_SYSTEM)) {
|
|
||||||
isSystemInclude = element.getAttribute(ATTRIBUTE_SYSTEM).equals(VALUE_TRUE);
|
|
||||||
}
|
|
||||||
return CoreModel.newIncludeEntry(
|
|
||||||
path,
|
|
||||||
includePath,
|
|
||||||
isSystemInclude,
|
|
||||||
isRecursive,
|
|
||||||
exclusionPatterns,
|
|
||||||
isExported);
|
|
||||||
}
|
|
||||||
|
|
||||||
case ICPathEntry.CDT_MACRO :
|
|
||||||
{
|
|
||||||
String macroName = element.getAttribute(ATTRIBUTE_NAME); //$NON-NLS-1$
|
|
||||||
String macroValue = element.getAttribute(ATTRIBUTE_VALUE); //$NON-NLS-1$
|
|
||||||
return CoreModel.newMacroEntry(path, macroName, macroValue, isRecursive, exclusionPatterns, isExported);
|
|
||||||
}
|
|
||||||
|
|
||||||
case ICPathEntry.CDT_CONTAINER :
|
|
||||||
{
|
|
||||||
String id = element.getAttribute(ATTRIBUTE_ID); //$NON-NLS-1$
|
|
||||||
return CoreModel.newContainerEntry(id, isExported);
|
|
||||||
}
|
|
||||||
|
|
||||||
default :
|
|
||||||
{
|
|
||||||
ICModelStatus status = new CModelStatus(ICModelStatus.ERROR, "CPathEntry: unknown kind (" + kindAttr + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
throw new CModelException(status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void encodeCPathEntries(Document doc, Element configRootElement, ICPathEntry[] entries) {
|
|
||||||
Element element;
|
|
||||||
IPath projectPath = getProject().getFullPath();
|
|
||||||
for (int i = 0; i < entries.length; i++) {
|
|
||||||
element = doc.createElement(PATH_ENTRY);
|
|
||||||
configRootElement.appendChild(element);
|
|
||||||
int kind = entries[i].getEntryKind();
|
|
||||||
|
|
||||||
// Set the kind
|
|
||||||
element.setAttribute(ATTRIBUTE_KIND, CPathEntry.kindToString(kind));
|
|
||||||
|
|
||||||
// Save the exclusions attributes
|
|
||||||
if (entries[i] instanceof ACPathEntry) {
|
|
||||||
ACPathEntry entry = (ACPathEntry) entries[i];
|
|
||||||
IPath[] exclusionPatterns = entry.getExclusionPatterns();
|
|
||||||
if (exclusionPatterns.length > 0) {
|
|
||||||
StringBuffer excludeRule = new StringBuffer(10);
|
|
||||||
for (int j = 0, max = exclusionPatterns.length; j < max; j++) {
|
|
||||||
if (j > 0) {
|
|
||||||
excludeRule.append('|');
|
|
||||||
}
|
|
||||||
excludeRule.append(exclusionPatterns[j]);
|
|
||||||
}
|
|
||||||
element.setAttribute(ATTRIBUTE_EXCLUDING, excludeRule.toString());
|
|
||||||
}
|
|
||||||
if (entry.isRecursive()) {
|
|
||||||
element.setAttribute(ATTRIBUTE_RECUSIVE, VALUE_TRUE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (kind == ICPathEntry.CDT_SOURCE) {
|
|
||||||
ISourceEntry source = (ISourceEntry) entries[i];
|
|
||||||
IPath path = source.getSourcePath();
|
|
||||||
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
|
||||||
IPath output = source.getOutputLocation();
|
|
||||||
if (output != null && output.isEmpty()) {
|
|
||||||
element.setAttribute(ATTRIBUTE_OUTPUT, output.toString());
|
|
||||||
}
|
|
||||||
} else if (kind == ICPathEntry.CDT_LIBRARY) {
|
|
||||||
ILibraryEntry lib = (ILibraryEntry) entries[i];
|
|
||||||
IPath path = lib.getLibraryPath();
|
|
||||||
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
|
||||||
if (lib.getSourceAttachmentPath() != null) {
|
|
||||||
element.setAttribute(ATTRIBUTE_SOURCEPATH, lib.getSourceAttachmentPath().toString());
|
|
||||||
}
|
|
||||||
if (lib.getSourceAttachmentRootPath() != null) {
|
|
||||||
element.setAttribute(ATTRIBUTE_ROOTPATH, lib.getSourceAttachmentRootPath().toString());
|
|
||||||
}
|
|
||||||
if (lib.getSourceAttachmentPrefixMapping() != null) {
|
|
||||||
element.setAttribute(ATTRIBUTE_PREFIXMAPPING, lib.getSourceAttachmentPrefixMapping().toString());
|
|
||||||
}
|
|
||||||
} else if (kind == ICPathEntry.CDT_PROJECT) {
|
|
||||||
IProjectEntry pentry = (IProjectEntry) entries[i];
|
|
||||||
IPath path = pentry.getProjectPath();
|
|
||||||
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
|
||||||
} else if (kind == ICPathEntry.CDT_INCLUDE) {
|
|
||||||
IIncludeEntry include = (IIncludeEntry) entries[i];
|
|
||||||
IPath path = include.getResourcePath();
|
|
||||||
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
|
||||||
IPath includePath = include.getIncludePath();
|
|
||||||
element.setAttribute(ATTRIBUTE_INCLUDE, includePath.toString());
|
|
||||||
if (include.isSystemInclude()) {
|
|
||||||
element.setAttribute(ATTRIBUTE_SYSTEM, VALUE_TRUE);
|
|
||||||
}
|
|
||||||
} else if (kind == ICPathEntry.CDT_MACRO) {
|
|
||||||
IMacroEntry macro = (IMacroEntry) entries[i];
|
|
||||||
IPath path = macro.getResourcePath();
|
|
||||||
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
|
||||||
element.setAttribute(ATTRIBUTE_NAME, macro.getMacroName());
|
|
||||||
element.setAttribute(ATTRIBUTE_VALUE, macro.getMacroValue());
|
|
||||||
} else if (kind == ICPathEntry.CDT_CONTAINER) {
|
|
||||||
IContainerEntry container = (IContainerEntry) entries[i];
|
|
||||||
element.setAttribute(ATTRIBUTE_ID, container.getId());
|
|
||||||
}
|
|
||||||
if (entries[i].isExported()) {
|
|
||||||
element.setAttribute(ATTRIBUTE_EXPORTED, VALUE_TRUE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,22 +13,23 @@
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.IContainerEntry;
|
import org.eclipse.cdt.core.model.IContainerEntry;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public class ContainerEntry extends CPathEntry implements IContainerEntry {
|
public class ContainerEntry extends PathEntry implements IContainerEntry {
|
||||||
|
|
||||||
String id;
|
IPath path;
|
||||||
|
|
||||||
public ContainerEntry(String id, boolean isExported) {
|
public ContainerEntry(IPath path, boolean isExported) {
|
||||||
super(IContainerEntry.CDT_CONTAINER, isExported);
|
super(IContainerEntry.CDT_CONTAINER, isExported);
|
||||||
this.id = id;
|
this.path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the id identifying this container.
|
* Returns the id identifying this container.
|
||||||
* @return String
|
* @return IPath
|
||||||
*/
|
*/
|
||||||
public String getId() {
|
public IPath getPath() {
|
||||||
return id;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
|
@ -37,12 +38,12 @@ public class ContainerEntry extends CPathEntry implements IContainerEntry {
|
||||||
if (!super.equals(container)) {
|
if (!super.equals(container)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (id == null) {
|
if (path == null) {
|
||||||
if (container.getId() != null) {
|
if (container.getPath() != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!id.equals(container.getId())) {
|
if (!path.equals(container.getPath())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,44 +9,48 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* QNX Software Systems - Initial API and implementation
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.IIncludeEntry;
|
import org.eclipse.cdt.core.model.IIncludeEntry;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
public class IncludeEntry extends ACPathEntry implements IIncludeEntry {
|
public class IncludeEntry extends APathEntry implements IIncludeEntry {
|
||||||
|
|
||||||
IPath resourcePath;
|
IPath resourcePath;
|
||||||
IPath includePath;
|
IPath includePath;
|
||||||
boolean isSystemInclude;
|
boolean isSystemInclude;
|
||||||
|
|
||||||
public IncludeEntry(IPath resourcePath, IPath includePath, boolean isSystemInclude,
|
public IncludeEntry(IPath resourcePath, IPath includePath, boolean isSystemInclude, boolean isRecursive,
|
||||||
boolean isRecursive, IPath[] exclusionPatterns, boolean isExported) {
|
IPath[] exclusionPatterns) {
|
||||||
super(IIncludeEntry.CDT_INCLUDE, isRecursive, exclusionPatterns, isExported);
|
super(IIncludeEntry.CDT_INCLUDE, isRecursive, exclusionPatterns, resourcePath == null || resourcePath.isEmpty());
|
||||||
this.resourcePath = resourcePath;
|
this.resourcePath = resourcePath == null ? new Path("") : resourcePath;
|
||||||
this.includePath = includePath;
|
this.includePath = includePath;
|
||||||
this.isSystemInclude = isSystemInclude;
|
this.isSystemInclude = isSystemInclude;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the affected resource by the include.
|
* Returns the affected resource by the include.
|
||||||
|
*
|
||||||
* @return IPath
|
* @return IPath
|
||||||
*/
|
*/
|
||||||
public IPath getResourcePath() {
|
public IPath getResourcePath() {
|
||||||
return resourcePath;
|
return resourcePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the include path
|
* Returns the include path
|
||||||
|
*
|
||||||
* @return IPath
|
* @return IPath
|
||||||
*/
|
*/
|
||||||
public IPath getIncludePath() {
|
public IPath getIncludePath() {
|
||||||
return includePath;
|
return includePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not it a system include path
|
* Whether or not it a system include path
|
||||||
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public boolean isSystemInclude() {
|
public boolean isSystemInclude() {
|
||||||
|
@ -55,7 +59,7 @@ public class IncludeEntry extends ACPathEntry implements IIncludeEntry {
|
||||||
|
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj instanceof IIncludeEntry) {
|
if (obj instanceof IIncludeEntry) {
|
||||||
IIncludeEntry otherEntry = (IIncludeEntry)obj;
|
IIncludeEntry otherEntry = (IIncludeEntry) obj;
|
||||||
if (!super.equals(otherEntry)) {
|
if (!super.equals(otherEntry)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -84,5 +88,5 @@ public class IncludeEntry extends ACPathEntry implements IIncludeEntry {
|
||||||
}
|
}
|
||||||
return super.equals(obj);
|
return super.equals(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
import org.eclipse.cdt.core.model.ILibraryEntry;
|
import org.eclipse.cdt.core.model.ILibraryEntry;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public class LibraryEntry extends CPathEntry implements ILibraryEntry {
|
public class LibraryEntry extends PathEntry implements ILibraryEntry {
|
||||||
|
|
||||||
IPath libraryPath;
|
IPath libraryPath;
|
||||||
IPath sourceAttachmentPath;
|
IPath sourceAttachmentPath;
|
||||||
|
|
|
@ -15,7 +15,7 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
import org.eclipse.cdt.core.model.IMacroEntry;
|
import org.eclipse.cdt.core.model.IMacroEntry;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public class MacroEntry extends ACPathEntry implements IMacroEntry {
|
public class MacroEntry extends APathEntry implements IMacroEntry {
|
||||||
|
|
||||||
IPath resourcePath;
|
IPath resourcePath;
|
||||||
String macroName;
|
String macroName;
|
||||||
|
|
|
@ -12,36 +12,36 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.model;
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.ICPathEntry;
|
import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
|
|
||||||
public class CPathEntry implements ICPathEntry {
|
public class PathEntry implements IPathEntry {
|
||||||
|
|
||||||
public int entryKind;
|
public int entryKind;
|
||||||
public boolean isExported;
|
public boolean isExported;
|
||||||
|
|
||||||
public CPathEntry(int entryKind, boolean isExported) {
|
public PathEntry(int entryKind, boolean isExported) {
|
||||||
|
|
||||||
this.entryKind = entryKind;
|
this.entryKind = entryKind;
|
||||||
this.isExported = isExported;
|
this.isExported = isExported;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.ICPathEntry#getEntryKind()
|
* @see org.eclipse.cdt.core.IPathEntry#getEntryKind()
|
||||||
*/
|
*/
|
||||||
public int getEntryKind() {
|
public int getEntryKind() {
|
||||||
return entryKind;
|
return entryKind;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.core.ICPathEntry#isExported()
|
* @see org.eclipse.cdt.core.IPathEntry#isExported()
|
||||||
*/
|
*/
|
||||||
public boolean isExported() {
|
public boolean isExported() {
|
||||||
return isExported;
|
return isExported;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj instanceof ICPathEntry) {
|
if (obj instanceof IPathEntry) {
|
||||||
ICPathEntry otherEntry = (ICPathEntry)obj;
|
IPathEntry otherEntry = (IPathEntry)obj;
|
||||||
if (entryKind != otherEntry.getEntryKind()) {
|
if (entryKind != otherEntry.getEntryKind()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -59,19 +59,19 @@ public class CPathEntry implements ICPathEntry {
|
||||||
static int kindFromString(String kindStr) {
|
static int kindFromString(String kindStr) {
|
||||||
|
|
||||||
if (kindStr.equalsIgnoreCase("prj")) //$NON-NLS-1$
|
if (kindStr.equalsIgnoreCase("prj")) //$NON-NLS-1$
|
||||||
return ICPathEntry.CDT_PROJECT;
|
return IPathEntry.CDT_PROJECT;
|
||||||
if (kindStr.equalsIgnoreCase("var")) //$NON-NLS-1$
|
if (kindStr.equalsIgnoreCase("var")) //$NON-NLS-1$
|
||||||
return ICPathEntry.CDT_VARIABLE;
|
return IPathEntry.CDT_VARIABLE;
|
||||||
if (kindStr.equalsIgnoreCase("src")) //$NON-NLS-1$
|
if (kindStr.equalsIgnoreCase("src")) //$NON-NLS-1$
|
||||||
return ICPathEntry.CDT_SOURCE;
|
return IPathEntry.CDT_SOURCE;
|
||||||
if (kindStr.equalsIgnoreCase("lib")) //$NON-NLS-1$
|
if (kindStr.equalsIgnoreCase("lib")) //$NON-NLS-1$
|
||||||
return ICPathEntry.CDT_LIBRARY;
|
return IPathEntry.CDT_LIBRARY;
|
||||||
if (kindStr.equalsIgnoreCase("inc")) //$NON-NLS-1$
|
if (kindStr.equalsIgnoreCase("inc")) //$NON-NLS-1$
|
||||||
return ICPathEntry.CDT_INCLUDE;
|
return IPathEntry.CDT_INCLUDE;
|
||||||
if (kindStr.equalsIgnoreCase("mac")) //$NON-NLS-1$
|
if (kindStr.equalsIgnoreCase("mac")) //$NON-NLS-1$
|
||||||
return ICPathEntry.CDT_MACRO;
|
return IPathEntry.CDT_MACRO;
|
||||||
if (kindStr.equalsIgnoreCase("con")) //$NON-NLS-1$
|
if (kindStr.equalsIgnoreCase("con")) //$NON-NLS-1$
|
||||||
return ICPathEntry.CDT_CONTAINER;
|
return IPathEntry.CDT_CONTAINER;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,19 +81,19 @@ public class CPathEntry implements ICPathEntry {
|
||||||
static String kindToString(int kind) {
|
static String kindToString(int kind) {
|
||||||
|
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case ICPathEntry.CDT_PROJECT :
|
case IPathEntry.CDT_PROJECT :
|
||||||
return "prj"; //$NON-NLS-1$
|
return "prj"; //$NON-NLS-1$
|
||||||
case ICPathEntry.CDT_SOURCE :
|
case IPathEntry.CDT_SOURCE :
|
||||||
return "src"; //$NON-NLS-1$
|
return "src"; //$NON-NLS-1$
|
||||||
case ICPathEntry.CDT_LIBRARY :
|
case IPathEntry.CDT_LIBRARY :
|
||||||
return "lib"; //$NON-NLS-1$
|
return "lib"; //$NON-NLS-1$
|
||||||
case ICPathEntry.CDT_VARIABLE :
|
case IPathEntry.CDT_VARIABLE :
|
||||||
return "var"; //$NON-NLS-1$
|
return "var"; //$NON-NLS-1$
|
||||||
case ICPathEntry.CDT_INCLUDE :
|
case IPathEntry.CDT_INCLUDE :
|
||||||
return "inc"; //$NON-NLS-1$
|
return "inc"; //$NON-NLS-1$
|
||||||
case ICPathEntry.CDT_MACRO :
|
case IPathEntry.CDT_MACRO :
|
||||||
return "mac"; //$NON-NLS-1$
|
return "mac"; //$NON-NLS-1$
|
||||||
case ICPathEntry.CDT_CONTAINER :
|
case IPathEntry.CDT_CONTAINER :
|
||||||
return "con"; //$NON-NLS-1$
|
return "con"; //$NON-NLS-1$
|
||||||
default :
|
default :
|
||||||
return "unknown"; //$NON-NLS-1$
|
return "unknown"; //$NON-NLS-1$
|
||||||
|
@ -107,25 +107,25 @@ public class CPathEntry implements ICPathEntry {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuffer buffer = new StringBuffer();
|
||||||
buffer.append('[');
|
buffer.append('[');
|
||||||
switch (getEntryKind()) {
|
switch (getEntryKind()) {
|
||||||
case ICPathEntry.CDT_LIBRARY :
|
case IPathEntry.CDT_LIBRARY :
|
||||||
buffer.append("CDT_LIBRARY"); //$NON-NLS-1$
|
buffer.append("CDT_LIBRARY"); //$NON-NLS-1$
|
||||||
break;
|
break;
|
||||||
case ICPathEntry.CDT_PROJECT :
|
case IPathEntry.CDT_PROJECT :
|
||||||
buffer.append("CDT_PROJECT"); //$NON-NLS-1$
|
buffer.append("CDT_PROJECT"); //$NON-NLS-1$
|
||||||
break;
|
break;
|
||||||
case ICPathEntry.CDT_SOURCE :
|
case IPathEntry.CDT_SOURCE :
|
||||||
buffer.append("CDT_SOURCE"); //$NON-NLS-1$
|
buffer.append("CDT_SOURCE"); //$NON-NLS-1$
|
||||||
break;
|
break;
|
||||||
case ICPathEntry.CDT_VARIABLE :
|
case IPathEntry.CDT_VARIABLE :
|
||||||
buffer.append("CDT_VARIABLE"); //$NON-NLS-1$
|
buffer.append("CDT_VARIABLE"); //$NON-NLS-1$
|
||||||
break;
|
break;
|
||||||
case ICPathEntry.CDT_INCLUDE :
|
case IPathEntry.CDT_INCLUDE :
|
||||||
buffer.append("CDT_INCLUDE"); //$NON-NLS-1$
|
buffer.append("CDT_INCLUDE"); //$NON-NLS-1$
|
||||||
break;
|
break;
|
||||||
case ICPathEntry.CDT_MACRO :
|
case IPathEntry.CDT_MACRO :
|
||||||
buffer.append("CDT_MACRO"); //$NON-NLS-1$
|
buffer.append("CDT_MACRO"); //$NON-NLS-1$
|
||||||
break;
|
break;
|
||||||
case ICPathEntry.CDT_CONTAINER :
|
case IPathEntry.CDT_CONTAINER :
|
||||||
buffer.append("CDT_CONTAINER"); //$NON-NLS-1$
|
buffer.append("CDT_CONTAINER"); //$NON-NLS-1$
|
||||||
break;
|
break;
|
||||||
}
|
}
|
|
@ -20,20 +20,21 @@ import java.util.Map;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
import org.eclipse.cdt.core.ICDescriptor;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CPathContainerInitializer;
|
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
import org.eclipse.cdt.core.model.ICModelStatus;
|
import org.eclipse.cdt.core.model.ICModelStatus;
|
||||||
import org.eclipse.cdt.core.model.ICPathContainer;
|
|
||||||
import org.eclipse.cdt.core.model.ICPathEntry;
|
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IContainerEntry;
|
import org.eclipse.cdt.core.model.IContainerEntry;
|
||||||
import org.eclipse.cdt.core.model.IIncludeEntry;
|
import org.eclipse.cdt.core.model.IIncludeEntry;
|
||||||
import org.eclipse.cdt.core.model.ILibraryEntry;
|
import org.eclipse.cdt.core.model.ILibraryEntry;
|
||||||
import org.eclipse.cdt.core.model.IMacroEntry;
|
import org.eclipse.cdt.core.model.IMacroEntry;
|
||||||
|
import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
|
import org.eclipse.cdt.core.model.IPathEntryContainer;
|
||||||
import org.eclipse.cdt.core.model.IProjectEntry;
|
import org.eclipse.cdt.core.model.IProjectEntry;
|
||||||
import org.eclipse.cdt.core.model.ISourceEntry;
|
import org.eclipse.cdt.core.model.ISourceEntry;
|
||||||
|
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.internal.runtime.Assert;
|
|
||||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
@ -42,7 +43,9 @@ import org.eclipse.core.runtime.IExtension;
|
||||||
import org.eclipse.core.runtime.IExtensionPoint;
|
import org.eclipse.core.runtime.IExtensionPoint;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
import org.eclipse.core.runtime.ISafeRunnable;
|
||||||
import org.eclipse.core.runtime.Path;
|
import org.eclipse.core.runtime.Path;
|
||||||
|
import org.eclipse.core.runtime.Platform;
|
||||||
import org.eclipse.core.runtime.Plugin;
|
import org.eclipse.core.runtime.Plugin;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
|
@ -53,11 +56,11 @@ import org.w3c.dom.NodeList;
|
||||||
* @author alain
|
* @author alain
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CPathEntryManager {
|
public class PathEntryManager {
|
||||||
|
|
||||||
static String CONTAINER_INITIALIZER_EXTPOINT_ID = "cpathContainerInitializer"; //$NON-NLS-1$
|
static String CONTAINER_INITIALIZER_EXTPOINT_ID = "pathEntryContainerInitializer"; //$NON-NLS-1$
|
||||||
static String PATH_ENTRY = "cpathentry"; //$NON-NLS-1$
|
static String PATH_ENTRY = "pathentry"; //$NON-NLS-1$
|
||||||
static String PATH_ENTRY_ID = "org.eclipse.cdt.core.cpathentry"; //$NON-NLS-1$
|
static String PATH_ENTRY_ID = "org.eclipse.cdt.core.pathentry"; //$NON-NLS-1$
|
||||||
static String ATTRIBUTE_KIND = "kind"; //$NON-NLS-1$
|
static String ATTRIBUTE_KIND = "kind"; //$NON-NLS-1$
|
||||||
static String ATTRIBUTE_PATH = "path"; //$NON-NLS-1$
|
static String ATTRIBUTE_PATH = "path"; //$NON-NLS-1$
|
||||||
static String ATTRIBUTE_EXPORTED = "exported"; //$NON-NLS-1$
|
static String ATTRIBUTE_EXPORTED = "exported"; //$NON-NLS-1$
|
||||||
|
@ -74,40 +77,52 @@ public class CPathEntryManager {
|
||||||
static String ATTRIBUTE_ID = "id"; //$NON-NLS-1$
|
static String ATTRIBUTE_ID = "id"; //$NON-NLS-1$
|
||||||
static String VALUE_TRUE = "true"; //$NON-NLS-1$
|
static String VALUE_TRUE = "true"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
final static IPathEntry[] EMPTY = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classpath containers pool
|
* An empty array of strings indicating that a project doesn't have any prerequesite projects.
|
||||||
|
*/
|
||||||
|
static final String[] NO_PREREQUISITES = new String[0];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pathentry containers pool
|
||||||
*/
|
*/
|
||||||
public static HashMap Containers = new HashMap(5);
|
public static HashMap Containers = new HashMap(5);
|
||||||
public static HashMap PreviousSessionContainers = new HashMap(5);
|
|
||||||
|
|
||||||
HashMap projectMap = new HashMap();
|
HashMap projectMap = new HashMap();
|
||||||
final ICPathEntry[] EMPTY = new ICPathEntry[0];
|
|
||||||
public final static ICPathContainer ContainerInitializationInProgress = new ICPathContainer() {
|
|
||||||
public ICPathEntry[] getCPathEntries() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public String getDescription() {
|
|
||||||
return "Container Initialization In Progress";
|
|
||||||
} //$NON-NLS-1$
|
|
||||||
};
|
|
||||||
|
|
||||||
public ICPathEntry[] getResolvedEntries(ICProject cproject) throws CModelException {
|
private static PathEntryManager pathEntryManager;
|
||||||
ICPathEntry[] entries = (ICPathEntry[]) projectMap.get(cproject);
|
|
||||||
|
private PathEntryManager() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the singleton.
|
||||||
|
*/
|
||||||
|
public static PathEntryManager getDefault() {
|
||||||
|
if (pathEntryManager == null) {
|
||||||
|
pathEntryManager = new PathEntryManager();
|
||||||
|
}
|
||||||
|
return pathEntryManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPathEntry[] getResolvedPathEntries(ICProject cproject) throws CModelException {
|
||||||
|
IPathEntry[] entries = (IPathEntry[]) projectMap.get(cproject);
|
||||||
if (entries == null) {
|
if (entries == null) {
|
||||||
entries = getRawCPathEntries(cproject);
|
entries = getRawPathEntries(cproject);
|
||||||
ArrayList list = new ArrayList();
|
ArrayList list = new ArrayList();
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (int i = 0; i < entries.length; i++) {
|
||||||
ICPathEntry entry = entries[i];
|
IPathEntry entry = entries[i];
|
||||||
// Expand the containers.
|
// Expand the containers.
|
||||||
if (entry.getEntryKind() == ICPathEntry.CDT_CONTAINER) {
|
if (entry.getEntryKind() == IPathEntry.CDT_CONTAINER) {
|
||||||
ICPathContainer container = getCPathContainer((IContainerEntry)entry, cproject);
|
IContainerEntry centry = (IContainerEntry) entry;
|
||||||
|
IPathEntryContainer container = getPathEntryContainer(centry, cproject);
|
||||||
if (container != null) {
|
if (container != null) {
|
||||||
ICPathEntry[] containerEntries = container.getCPathEntries();
|
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++) {
|
||||||
ICPathEntry cEntry = containerEntries[i];
|
if (entry.isExported()) {
|
||||||
if (cEntry.isExported()) {
|
list.add(containerEntries[i]);
|
||||||
list.add(cEntry);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,24 +131,246 @@ public class CPathEntryManager {
|
||||||
list.add(entry);
|
list.add(entry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
entries = new ICPathEntry[list.size()];
|
entries = new IPathEntry[list.size()];
|
||||||
list.toArray(entries);
|
list.toArray(entries);
|
||||||
projectMap.put(cproject, entries);
|
projectMap.put(cproject, entries);
|
||||||
}
|
}
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRawCPathEntries(ICProject cproject, ICPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException {
|
public void setRawPathEntries(ICProject cproject, IPathEntry[] newEntries, IProgressMonitor monitor) throws CModelException {
|
||||||
//try {
|
try {
|
||||||
// SetCPathEntriesOperation op = new SetCPathEntriesOperation(cproject, getRawCPathEntries(cproject), newEntries);
|
SetPathEntriesOperation op = new SetPathEntriesOperation(cproject, getRawPathEntries(cproject), newEntries);
|
||||||
// runOperation(op, monitor);
|
CModelManager.getDefault().runOperation(op, monitor);
|
||||||
//} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
// throw new CModelException(e);
|
throw new CModelException(e);
|
||||||
//}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPathEntry[] getRawPathEntries(ICProject cproject) throws CModelException {
|
||||||
|
ArrayList pathEntries = new ArrayList();
|
||||||
|
try {
|
||||||
|
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(cproject.getProject());
|
||||||
|
Element element = cdesc.getProjectData(PATH_ENTRY_ID);
|
||||||
|
NodeList list = element.getChildNodes();
|
||||||
|
for (int i = 0; i < list.getLength(); i++) {
|
||||||
|
Node childNode = list.item(i);
|
||||||
|
if (childNode.getNodeType() == Node.ELEMENT_NODE) {
|
||||||
|
if (childNode.getNodeName().equals(PATH_ENTRY)) {
|
||||||
|
pathEntries.add(decodePathEntry(cproject, (Element) childNode));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
throw new CModelException(e);
|
||||||
|
}
|
||||||
|
return (IPathEntry[]) pathEntries.toArray(EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPathEntryContainer(ICProject[] affectedProjects, IPathEntryContainer newContainer, IProgressMonitor monitor) throws CModelException {
|
||||||
|
|
||||||
|
if (monitor != null && monitor.isCanceled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
IPath containerPath = newContainer.getPath();
|
||||||
|
final int projectLength = affectedProjects.length;
|
||||||
|
final ICProject[] modifiedProjects = new ICProject[projectLength];
|
||||||
|
System.arraycopy(affectedProjects, 0, modifiedProjects, 0, projectLength);
|
||||||
|
|
||||||
|
// filter out unmodified project containers
|
||||||
|
int remaining = 0;
|
||||||
|
for (int i = 0; i < projectLength; i++) {
|
||||||
|
|
||||||
|
if (monitor != null && monitor.isCanceled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ICProject affectedProject = affectedProjects[i];
|
||||||
|
|
||||||
|
boolean found = false;
|
||||||
|
if (CoreModel.getDefault().hasCCNature(affectedProject.getProject())) {
|
||||||
|
IPathEntry[] rawPath = affectedProject.getRawPathEntries();
|
||||||
|
for (int j = 0, cpLength = rawPath.length; j < cpLength; j++) {
|
||||||
|
IPathEntry entry = rawPath[j];
|
||||||
|
if (entry.getEntryKind() == IPathEntry.CDT_CONTAINER) {
|
||||||
|
IContainerEntry cont = (IContainerEntry) entry;
|
||||||
|
if (cont.getPath().equals(containerPath)) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
// filter out this project - does not reference the container path
|
||||||
|
modifiedProjects[i] = null;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
IPathEntryContainer oldContainer = containerGet(affectedProject, containerPath);
|
||||||
|
if (oldContainer != null && oldContainer.equals(newContainer)) {
|
||||||
|
modifiedProjects[i] = null; // filter out this project - container did not change
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
remaining++;
|
||||||
|
containerPut(affectedProject, containerPath, newContainer);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nothing change.
|
||||||
|
if (remaining == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// trigger model refresh
|
||||||
|
try {
|
||||||
|
//final boolean canChangeResources = !ResourcesPlugin.getWorkspace().isTreeLocked();
|
||||||
|
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
|
||||||
|
public void run(IProgressMonitor progressMonitor) throws CoreException {
|
||||||
|
for (int i = 0; i < projectLength; i++) {
|
||||||
|
|
||||||
|
if (progressMonitor != null && progressMonitor.isCanceled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ICProject affectedProject = (ICProject) modifiedProjects[i];
|
||||||
|
if (affectedProject == null) {
|
||||||
|
continue; // was filtered out
|
||||||
|
}
|
||||||
|
// force a refresh of the affected project (will compute deltas)
|
||||||
|
affectedProject.setRawPathEntries(affectedProject.getRawPathEntries(), progressMonitor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, monitor);
|
||||||
|
} catch (CoreException e) {
|
||||||
|
if (e instanceof CModelException) {
|
||||||
|
throw (CModelException) e;
|
||||||
|
} else {
|
||||||
|
throw new CModelException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPathEntryContainer getPathEntryContainer(IContainerEntry entry, ICProject cproject) throws CModelException {
|
||||||
|
return getPathEntryContainer(entry.getPath(), cproject);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPathEntryContainer getPathEntryContainer(final IPath containerPath, final ICProject project) throws CModelException {
|
||||||
|
|
||||||
|
// Try the cache.
|
||||||
|
IPathEntryContainer container = containerGet(project, containerPath);
|
||||||
|
|
||||||
|
if (container == null) {
|
||||||
|
final PathEntryContainerInitializer initializer = getPathEntryContainerInitializer(containerPath.segment(0));
|
||||||
|
if (initializer != null) {
|
||||||
|
containerPut(project, containerPath, container);
|
||||||
|
boolean ok = false;
|
||||||
|
try {
|
||||||
|
// wrap initializer call with Safe runnable in case initializer would be
|
||||||
|
// causing some grief
|
||||||
|
Platform.run(new ISafeRunnable() {
|
||||||
|
public void handleException(Throwable exception) {
|
||||||
|
//Util.log(exception, "Exception occurred in container initializer: "+initializer); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
public void run() throws Exception {
|
||||||
|
initializer.initialize(containerPath, project);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// retrieve value (if initialization was successful)
|
||||||
|
container = containerGet(project, containerPath);
|
||||||
|
ok = true;
|
||||||
|
} finally {
|
||||||
|
if (!ok) {
|
||||||
|
containerPut(project, containerPath, null); // flush cache
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper method finding the container initializer registered for a given container ID or <code>null</code>
|
||||||
|
* if none was found while iterating over the contributions to extension point to the extension point
|
||||||
|
* "org.eclipse.cdt.core.PathEntryContainerInitializer".
|
||||||
|
* <p>
|
||||||
|
* A containerID is the first segment of any container path, used to identify the registered container initializer.
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* @param containerID -
|
||||||
|
* a containerID identifying a registered initializer
|
||||||
|
* @return PathEntryContainerInitializer - the registered container initializer or <code>null</code> if none was
|
||||||
|
* found.
|
||||||
|
*/
|
||||||
|
public PathEntryContainerInitializer getPathEntryContainerInitializer(String containerID) {
|
||||||
|
|
||||||
|
Plugin core = CCorePlugin.getDefault();
|
||||||
|
if (core == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
IExtensionPoint extension = core.getDescriptor().getExtensionPoint(CONTAINER_INITIALIZER_EXTPOINT_ID);
|
||||||
|
if (extension != null) {
|
||||||
|
IExtension[] extensions = extension.getExtensions();
|
||||||
|
for (int i = 0; i < extensions.length; i++) {
|
||||||
|
IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
|
||||||
|
for (int j = 0; j < configElements.length; j++) {
|
||||||
|
String initializerID = configElements[j].getAttribute("id"); //$NON-NLS-1$
|
||||||
|
if (initializerID != null && initializerID.equals(containerID)) {
|
||||||
|
try {
|
||||||
|
Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
|
||||||
|
if (execExt instanceof PathEntryContainerInitializer) {
|
||||||
|
return (PathEntryContainerInitializer) execExt;
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
// executable extension could not be created:
|
||||||
|
// ignore this initializer if
|
||||||
|
//e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPathEntryContainer containerGet(ICProject project, IPath containerPath) {
|
||||||
|
Map projectContainers = (Map) Containers.get(project);
|
||||||
|
if (projectContainers == null) {
|
||||||
|
projectContainers = new HashMap();
|
||||||
|
Containers.put(project, projectContainers);
|
||||||
|
}
|
||||||
|
IPathEntryContainer container = (IPathEntryContainer) projectContainers.get(containerPath);
|
||||||
|
return container;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void containerPut(ICProject project, IPath containerPath, IPathEntryContainer container) {
|
||||||
|
Map projectContainers = (Map) Containers.get(project);
|
||||||
|
if (projectContainers == null) {
|
||||||
|
projectContainers = new HashMap();
|
||||||
|
Containers.put(project, projectContainers);
|
||||||
|
}
|
||||||
|
projectContainers.put(containerPath, container);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] projectPrerequisites(IPathEntry[] entries) throws CModelException {
|
||||||
|
ArrayList prerequisites = new ArrayList();
|
||||||
|
for (int i = 0, length = entries.length; i < length; i++) {
|
||||||
|
if (entries[i].getEntryKind() == IPathEntry.CDT_PROJECT) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
return NO_PREREQUISITES;
|
||||||
|
}
|
||||||
|
public ICElementDelta[] 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(CProject.PATH_ENTRY_ID);
|
Element rootElement = descriptor.getProjectData(PATH_ENTRY_ID);
|
||||||
// Clear out all current children
|
// Clear out all current children
|
||||||
Node child = rootElement.getFirstChild();
|
Node child = rootElement.getFirstChild();
|
||||||
while (child != null) {
|
while (child != null) {
|
||||||
|
@ -145,169 +382,112 @@ public class CPathEntryManager {
|
||||||
if (newEntries != null && newEntries.length > 0) {
|
if (newEntries != null && newEntries.length > 0) {
|
||||||
// Serialize the include paths
|
// Serialize the include paths
|
||||||
Document doc = rootElement.getOwnerDocument();
|
Document doc = rootElement.getOwnerDocument();
|
||||||
encodeCPathEntries(cproject.getProject().getFullPath(), 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPathEntry[] getRawCPathEntries(ICProject cproject) throws CModelException {
|
private ICElementDelta[] generatePathEntryDeltas(ICProject cproject, IPathEntry[] oldEntries, IPathEntry[] newEntries) {
|
||||||
ArrayList pathEntries = new ArrayList();
|
ArrayList list = new ArrayList();
|
||||||
try {
|
CModelManager manager = CModelManager.getDefault();
|
||||||
ICDescriptor cdesc = CCorePlugin.getDefault().getCProjectDescription(cproject.getProject());
|
boolean needToUpdateDependents = false;
|
||||||
Element element = cdesc.getProjectData(PATH_ENTRY_ID);
|
boolean hasDelta = false;
|
||||||
NodeList list = element.getChildNodes();
|
|
||||||
for (int i = 0; i < list.getLength(); i++) {
|
// Check the removed entries.
|
||||||
Node childNode = list.item(i);
|
if (oldEntries != null) {
|
||||||
if (childNode.getNodeType() == Node.ELEMENT_NODE) {
|
for (int i = 0; i < oldEntries.length; i++) {
|
||||||
if (childNode.getNodeName().equals(PATH_ENTRY)) {
|
boolean found = false;
|
||||||
pathEntries.add(decodeCPathEntry(cproject, (Element) childNode));
|
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], ICElementDelta.F_REMOVED_FROM_CPATHENTRY);
|
||||||
|
if (delta != null) {
|
||||||
|
list.add(delta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
|
||||||
throw new CModelException(e);
|
|
||||||
}
|
}
|
||||||
return (ICPathEntry[]) pathEntries.toArray(new ICPathEntry[0]);
|
// Check the new entries.
|
||||||
|
if (newEntries != null) {
|
||||||
|
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], ICElementDelta.F_ADDED_TO_CPATHENTRY);
|
||||||
|
if (delta != null) {
|
||||||
|
list.add(delta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ICElementDelta[] deltas = new ICElementDelta[list.size()];
|
||||||
|
list.toArray(deltas);
|
||||||
|
return deltas;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCPathContainer(
|
/**
|
||||||
final IPath containerPath,
|
* return a delta, with the specified change flag.
|
||||||
ICProject[] affectedProjects,
|
*/
|
||||||
ICPathContainer[] respectiveContainers,
|
protected ICElementDelta makePathEntryDelta(ICProject cproject, IPathEntry entry, int flag) {
|
||||||
IProgressMonitor monitor)
|
int kind = entry.getEntryKind();
|
||||||
throws CModelException {
|
ICElement celement = null;
|
||||||
|
if (kind == IPathEntry.CDT_SOURCE) {
|
||||||
if (affectedProjects.length != respectiveContainers.length)
|
ISourceEntry source = (ISourceEntry) entry;
|
||||||
Assert.isTrue(false, "Projects and containers collections should have the same size"); //$NON-NLS-1$
|
IPath path = source.getSourcePath();
|
||||||
|
celement = CoreModel.getDefault().create(path);
|
||||||
if (monitor != null && monitor.isCanceled())
|
} else if (kind == IPathEntry.CDT_LIBRARY) {
|
||||||
return;
|
//ILibraryEntry lib = (ILibraryEntry) entry;
|
||||||
|
//IPath path = lib.getLibraryPath();
|
||||||
final int projectLength = affectedProjects.length;
|
celement = cproject;
|
||||||
final ICProject[] modifiedProjects = new ICProject[projectLength];
|
} else if (kind == IPathEntry.CDT_PROJECT) {
|
||||||
System.arraycopy(affectedProjects, 0, modifiedProjects, 0, projectLength);
|
//IProjectEntry pentry = (IProjectEntry) entry;
|
||||||
ICPathEntry[][] oldResolvedPaths = new ICPathEntry[projectLength][];
|
//IPath path = pentry.getProjectPath();
|
||||||
|
celement = cproject;
|
||||||
// filter out unmodified project containers
|
} else if (kind == IPathEntry.CDT_INCLUDE) {
|
||||||
int remaining = 0;
|
IIncludeEntry include = (IIncludeEntry) entry;
|
||||||
for (int i = 0; i < projectLength; i++) {
|
IPath path = include.getResourcePath();
|
||||||
|
celement = CoreModel.getDefault().create(path);
|
||||||
if (monitor != null && monitor.isCanceled())
|
} else if (kind == IPathEntry.CDT_MACRO) {
|
||||||
return;
|
IMacroEntry macro = (IMacroEntry) entry;
|
||||||
|
IPath path = macro.getResourcePath();
|
||||||
ICProject affectedProject = affectedProjects[i];
|
celement = CoreModel.getDefault().create(path);
|
||||||
ICPathContainer newContainer = respectiveContainers[i];
|
} else if (kind == IPathEntry.CDT_CONTAINER) {
|
||||||
|
IContainerEntry container = (IContainerEntry) entry;
|
||||||
if (newContainer == null)
|
celement = cproject;
|
||||||
newContainer = ContainerInitializationInProgress; // 30920 - prevent infinite loop
|
|
||||||
|
|
||||||
boolean found = false;
|
|
||||||
if (CoreModel.getDefault().hasCCNature(affectedProject.getProject())) {
|
|
||||||
ICPathEntry[] rawCPath = affectedProject.getRawCPathEntries();
|
|
||||||
for (int j = 0, cpLength = rawCPath.length; j < cpLength; j++) {
|
|
||||||
ICPathEntry entry = rawCPath[j];
|
|
||||||
if (entry.getEntryKind() == ICPathEntry.CDT_CONTAINER) {
|
|
||||||
IContainerEntry cont = (IContainerEntry) entry;
|
|
||||||
if (cont.getId().equals(containerPath.segment(0))) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
modifiedProjects[i] = null;
|
|
||||||
// filter out this project - does not reference the container path, or isnt't yet Java project
|
|
||||||
containerPut(affectedProject, containerPath, newContainer);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ICPathContainer oldContainer = containerGet(affectedProject, containerPath);
|
|
||||||
if (oldContainer == ContainerInitializationInProgress) {
|
|
||||||
Map previousContainerValues = (Map) PreviousSessionContainers.get(affectedProject);
|
|
||||||
if (previousContainerValues != null) {
|
|
||||||
ICPathContainer previousContainer = (ICPathContainer) previousContainerValues.get(containerPath);
|
|
||||||
if (previousContainer != null) {
|
|
||||||
if (true) {
|
|
||||||
System.out.println("CPContainer INIT - reentering access to project container: [" + affectedProject.getElementName() + "] " + containerPath + " during its initialization, will see previous value: " + previousContainer.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
||||||
}
|
|
||||||
containerPut(affectedProject, containerPath, previousContainer);
|
|
||||||
}
|
|
||||||
oldContainer = null;
|
|
||||||
//33695 - cannot filter out restored container, must update affected project to reset cached CP
|
|
||||||
} else {
|
|
||||||
oldContainer = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (oldContainer != null && oldContainer.equals(respectiveContainers[i])) {
|
|
||||||
modifiedProjects[i] = null; // filter out this project - container did not change
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
remaining++;
|
|
||||||
oldResolvedPaths[i] = affectedProject.getResolvedCPathEntries();
|
|
||||||
containerPut(affectedProject, containerPath, newContainer);
|
|
||||||
}
|
}
|
||||||
|
if (celement != null) {
|
||||||
// Nothing change.
|
CElementDelta delta = new CElementDelta(cproject.getCModel());
|
||||||
if (remaining == 0)
|
delta.changed(celement, flag);
|
||||||
return;
|
return delta;
|
||||||
|
|
||||||
// trigger model refresh
|
|
||||||
try {
|
|
||||||
//final boolean canChangeResources = !ResourcesPlugin.getWorkspace().isTreeLocked();
|
|
||||||
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
|
|
||||||
public void run(IProgressMonitor progressMonitor) throws CoreException {
|
|
||||||
for (int i = 0; i < projectLength; i++) {
|
|
||||||
|
|
||||||
if (progressMonitor != null && progressMonitor.isCanceled())
|
|
||||||
return;
|
|
||||||
|
|
||||||
ICProject affectedProject = (ICProject) modifiedProjects[i];
|
|
||||||
if (affectedProject == null)
|
|
||||||
continue; // was filtered out
|
|
||||||
|
|
||||||
if (true) {
|
|
||||||
System.out.println("CPContainer SET - updating affected project: [" + affectedProject.getElementName() + "] due to setting container: " + containerPath); //$NON-NLS-1$ //$NON-NLS-2$
|
|
||||||
}
|
|
||||||
|
|
||||||
// force a refresh of the affected project (will compute deltas)
|
|
||||||
affectedProject.setRawCPathEntries(affectedProject.getRawCPathEntries(), progressMonitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, monitor);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
if (true) {
|
|
||||||
System.out.println("CPContainer SET - FAILED DUE TO EXCEPTION: " + containerPath); //$NON-NLS-1$
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if (e instanceof CModelException) {
|
|
||||||
throw (CModelException) e;
|
|
||||||
} else {
|
|
||||||
throw new CModelException(e);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
for (int i = 0; i < projectLength; i++) {
|
|
||||||
if (respectiveContainers[i] == null) {
|
|
||||||
containerPut(affectedProjects[i], containerPath, null); // reset init in progress marker
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICPathContainer getCPathContainer(IContainerEntry entry, ICProject cproject) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getRegisteredContainerIDs() {
|
static String[] getRegisteredContainerIDs() {
|
||||||
Plugin cdtCorePlugin = CCorePlugin.getDefault();
|
Plugin core = CCorePlugin.getDefault();
|
||||||
if (cdtCorePlugin == null)
|
if (core == null) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
ArrayList containerIDList = new ArrayList(5);
|
ArrayList containerIDList = new ArrayList(5);
|
||||||
IExtensionPoint extension = cdtCorePlugin.getDescriptor().getExtensionPoint(CONTAINER_INITIALIZER_EXTPOINT_ID);
|
IExtensionPoint extension = core.getDescriptor().getExtensionPoint(CONTAINER_INITIALIZER_EXTPOINT_ID);
|
||||||
if (extension != null) {
|
if (extension != null) {
|
||||||
IExtension[] extensions = extension.getExtensions();
|
IExtension[] extensions = extension.getExtensions();
|
||||||
for (int i = 0; i < extensions.length; i++) {
|
for (int i = 0; i < extensions.length; i++) {
|
||||||
|
@ -324,93 +504,12 @@ public class CPathEntryManager {
|
||||||
return containerIDs;
|
return containerIDs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static IPathEntry decodePathEntry(ICProject cProject, Element element) throws CModelException {
|
||||||
* Helper method finding the classpath container initializer registered for a given classpath container ID or <code>null</code>
|
|
||||||
* if none was found while iterating over the contributions to extension point to the extension point
|
|
||||||
* "org.eclipse.jdt.core.classpathContainerInitializer".
|
|
||||||
* <p>
|
|
||||||
* A containerID is the first segment of any container path, used to identify the registered container initializer.
|
|
||||||
* <p>
|
|
||||||
*
|
|
||||||
* @param containerID -
|
|
||||||
* a containerID identifying a registered initializer
|
|
||||||
* @return ClasspathContainerInitializer - the registered classpath container initializer or <code>null</code> if none was
|
|
||||||
* found.
|
|
||||||
* @since 2.1
|
|
||||||
*/
|
|
||||||
public static CPathContainerInitializer getCPathContainerInitializer(String containerID) {
|
|
||||||
|
|
||||||
Plugin cdtCorePlugin = CCorePlugin.getDefault();
|
|
||||||
if (cdtCorePlugin == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
IExtensionPoint extension = cdtCorePlugin.getDescriptor().getExtensionPoint(CONTAINER_INITIALIZER_EXTPOINT_ID);
|
|
||||||
if (extension != null) {
|
|
||||||
IExtension[] extensions = extension.getExtensions();
|
|
||||||
for (int i = 0; i < extensions.length; i++) {
|
|
||||||
IConfigurationElement[] configElements = extensions[i].getConfigurationElements();
|
|
||||||
for (int j = 0; j < configElements.length; j++) {
|
|
||||||
String initializerID = configElements[j].getAttribute("id"); //$NON-NLS-1$
|
|
||||||
if (initializerID != null && initializerID.equals(containerID)) {
|
|
||||||
if (true) {
|
|
||||||
System.out.println("CPContainer INIT - found initializer: " + containerID + " --> " + configElements[j].getAttribute("class")); //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Object execExt = configElements[j].createExecutableExtension("class"); //$NON-NLS-1$
|
|
||||||
if (execExt instanceof CPathContainerInitializer) {
|
|
||||||
return (CPathContainerInitializer) execExt;
|
|
||||||
}
|
|
||||||
} catch (CoreException e) {
|
|
||||||
// executable extension could not be created: ignore this initializer if
|
|
||||||
System.out.println("CPContainer INIT - failed to instanciate initializer: " + containerID + " --> " + configElements[j].getAttribute("class")); //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ICPathContainer containerGet(ICProject project, IPath containerPath) {
|
|
||||||
Map projectContainers = (Map) Containers.get(project);
|
|
||||||
if (projectContainers == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
ICPathContainer container = (ICPathContainer) projectContainers.get(containerPath);
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void containerPut(ICProject project, IPath containerPath, ICPathContainer container) {
|
|
||||||
|
|
||||||
Map projectContainers = (Map) Containers.get(project);
|
|
||||||
if (projectContainers == null) {
|
|
||||||
projectContainers = new HashMap(1);
|
|
||||||
Containers.put(project, projectContainers);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (container == null) {
|
|
||||||
projectContainers.remove(containerPath);
|
|
||||||
Map previousContainers = (Map) PreviousSessionContainers.get(project);
|
|
||||||
if (previousContainers != null) {
|
|
||||||
previousContainers.remove(containerPath);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
projectContainers.put(containerPath, container);
|
|
||||||
}
|
|
||||||
|
|
||||||
// do not write out intermediate initialization value
|
|
||||||
if (container == ContainerInitializationInProgress) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ICPathEntry decodeCPathEntry(ICProject cProject, Element element) throws CModelException {
|
|
||||||
IPath projectPath = cProject.getProject().getFullPath();
|
IPath projectPath = cProject.getProject().getFullPath();
|
||||||
|
|
||||||
// kind
|
// kind
|
||||||
String kindAttr = element.getAttribute(ATTRIBUTE_KIND);
|
String kindAttr = element.getAttribute(ATTRIBUTE_KIND);
|
||||||
int kind = CPathEntry.kindFromString(kindAttr);
|
int kind = PathEntry.kindFromString(kindAttr);
|
||||||
|
|
||||||
// exported flag
|
// exported flag
|
||||||
boolean isExported = false;
|
boolean isExported = false;
|
||||||
|
@ -421,7 +520,7 @@ public class CPathEntryManager {
|
||||||
// ensure path is absolute
|
// ensure path is absolute
|
||||||
String pathAttr = element.getAttribute(ATTRIBUTE_PATH);
|
String pathAttr = element.getAttribute(ATTRIBUTE_PATH);
|
||||||
IPath path = new Path(pathAttr);
|
IPath path = new Path(pathAttr);
|
||||||
if (kind != ICPathEntry.CDT_VARIABLE && !path.isAbsolute()) {
|
if (kind != IPathEntry.CDT_VARIABLE && !path.isAbsolute()) {
|
||||||
path = projectPath.append(path);
|
path = projectPath.append(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,7 +534,7 @@ public class CPathEntryManager {
|
||||||
|
|
||||||
// exclusion patterns (optional)
|
// exclusion patterns (optional)
|
||||||
String exclusion = element.getAttribute(ATTRIBUTE_EXCLUDING);
|
String exclusion = element.getAttribute(ATTRIBUTE_EXCLUDING);
|
||||||
IPath[] exclusionPatterns = ACPathEntry.NO_EXCLUSION_PATTERNS;
|
IPath[] exclusionPatterns = APathEntry.NO_EXCLUSION_PATTERNS;
|
||||||
if (!exclusion.equals("")) { //$NON-NLS-1$
|
if (!exclusion.equals("")) { //$NON-NLS-1$
|
||||||
char[][] patterns = CharOperation.splitOn('|', exclusion.toCharArray());
|
char[][] patterns = CharOperation.splitOn('|', exclusion.toCharArray());
|
||||||
int patternCount;
|
int patternCount;
|
||||||
|
@ -456,10 +555,10 @@ public class CPathEntryManager {
|
||||||
|
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
|
|
||||||
case ICPathEntry.CDT_PROJECT :
|
case IPathEntry.CDT_PROJECT :
|
||||||
return CoreModel.newProjectEntry(path, isExported);
|
return CoreModel.newProjectEntry(path, isExported);
|
||||||
|
|
||||||
case ICPathEntry.CDT_LIBRARY :
|
case IPathEntry.CDT_LIBRARY :
|
||||||
return CoreModel.newLibraryEntry(
|
return CoreModel.newLibraryEntry(
|
||||||
path,
|
path,
|
||||||
sourceAttachmentPath,
|
sourceAttachmentPath,
|
||||||
|
@ -467,10 +566,10 @@ public class CPathEntryManager {
|
||||||
sourceAttachmentPrefixMapping,
|
sourceAttachmentPrefixMapping,
|
||||||
isExported);
|
isExported);
|
||||||
|
|
||||||
case ICPathEntry.CDT_SOURCE :
|
case IPathEntry.CDT_SOURCE :
|
||||||
{
|
{
|
||||||
// custom output location
|
// custom output location
|
||||||
IPath outputLocation = element.hasAttribute(ATTRIBUTE_OUTPUT) ? projectPath.append(element.getAttribute(ATTRIBUTE_OUTPUT)) : null; //$NON-NLS-1$ //$NON-NLS-2$
|
IPath outputLocation = element.hasAttribute(ATTRIBUTE_OUTPUT) ? projectPath.append(element.getAttribute(ATTRIBUTE_OUTPUT)) : null;
|
||||||
// must be an entry in this project or specify another
|
// must be an entry in this project or specify another
|
||||||
// project
|
// project
|
||||||
String projSegment = path.segment(0);
|
String projSegment = path.segment(0);
|
||||||
|
@ -481,11 +580,7 @@ public class CPathEntryManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// case ICPathEntry.CDT_VARIABLE :
|
case IPathEntry.CDT_INCLUDE :
|
||||||
// return CoreModel.newVariableEntry(path,
|
|
||||||
// sourceAttachmentPath, sourceAttachmentRootPath);
|
|
||||||
|
|
||||||
case ICPathEntry.CDT_INCLUDE :
|
|
||||||
{
|
{
|
||||||
// include path info (optional
|
// include path info (optional
|
||||||
IPath includePath =
|
IPath includePath =
|
||||||
|
@ -500,45 +595,43 @@ public class CPathEntryManager {
|
||||||
includePath,
|
includePath,
|
||||||
isSystemInclude,
|
isSystemInclude,
|
||||||
isRecursive,
|
isRecursive,
|
||||||
exclusionPatterns,
|
exclusionPatterns);
|
||||||
isExported);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case ICPathEntry.CDT_MACRO :
|
case IPathEntry.CDT_MACRO :
|
||||||
{
|
{
|
||||||
String macroName = element.getAttribute(ATTRIBUTE_NAME); //$NON-NLS-1$
|
String macroName = element.getAttribute(ATTRIBUTE_NAME);
|
||||||
String macroValue = element.getAttribute(ATTRIBUTE_VALUE); //$NON-NLS-1$
|
String macroValue = element.getAttribute(ATTRIBUTE_VALUE);
|
||||||
return CoreModel.newMacroEntry(path, macroName, macroValue, isRecursive, exclusionPatterns, isExported);
|
return CoreModel.newMacroEntry(path, macroName, macroValue, isRecursive, exclusionPatterns, isExported);
|
||||||
}
|
}
|
||||||
|
|
||||||
case ICPathEntry.CDT_CONTAINER :
|
case IPathEntry.CDT_CONTAINER :
|
||||||
{
|
{
|
||||||
String id = element.getAttribute(ATTRIBUTE_ID); //$NON-NLS-1$
|
IPath id = new Path(element.getAttribute(ATTRIBUTE_ID));
|
||||||
return CoreModel.newContainerEntry(id, isExported);
|
return CoreModel.newContainerEntry(id, isExported);
|
||||||
}
|
}
|
||||||
|
|
||||||
default :
|
default :
|
||||||
{
|
{
|
||||||
ICModelStatus status = new CModelStatus(ICModelStatus.ERROR, "CPathEntry: unknown kind (" + kindAttr + ")"); //$NON-NLS-1$
|
ICModelStatus status = new CModelStatus(ICModelStatus.ERROR, "PathEntry: unknown kind (" + kindAttr + ")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
throw new CModelException(status);
|
throw new CModelException(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void encodeCPathEntries(IPath projectPath, Document doc, Element configRootElement, ICPathEntry[] entries) {
|
static void encodePathEntries(IPath projectPath, Document doc, Element configRootElement, IPathEntry[] entries) {
|
||||||
Element element;
|
Element element;
|
||||||
//IPath projectPath = getProject().getFullPath();
|
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (int i = 0; i < entries.length; i++) {
|
||||||
element = doc.createElement(PATH_ENTRY);
|
element = doc.createElement(PATH_ENTRY);
|
||||||
configRootElement.appendChild(element);
|
configRootElement.appendChild(element);
|
||||||
int kind = entries[i].getEntryKind();
|
int kind = entries[i].getEntryKind();
|
||||||
|
|
||||||
// Set the kind
|
// Set the kind
|
||||||
element.setAttribute(ATTRIBUTE_KIND, CPathEntry.kindToString(kind));
|
element.setAttribute(ATTRIBUTE_KIND, PathEntry.kindToString(kind));
|
||||||
|
|
||||||
// Save the exclusions attributes
|
// Save the exclusions attributes
|
||||||
if (entries[i] instanceof ACPathEntry) {
|
if (entries[i] instanceof APathEntry) {
|
||||||
ACPathEntry entry = (ACPathEntry) entries[i];
|
APathEntry entry = (APathEntry) entries[i];
|
||||||
IPath[] exclusionPatterns = entry.getExclusionPatterns();
|
IPath[] exclusionPatterns = entry.getExclusionPatterns();
|
||||||
if (exclusionPatterns.length > 0) {
|
if (exclusionPatterns.length > 0) {
|
||||||
StringBuffer excludeRule = new StringBuffer(10);
|
StringBuffer excludeRule = new StringBuffer(10);
|
||||||
|
@ -555,7 +648,7 @@ public class CPathEntryManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kind == ICPathEntry.CDT_SOURCE) {
|
if (kind == IPathEntry.CDT_SOURCE) {
|
||||||
ISourceEntry source = (ISourceEntry) entries[i];
|
ISourceEntry source = (ISourceEntry) entries[i];
|
||||||
IPath path = source.getSourcePath();
|
IPath path = source.getSourcePath();
|
||||||
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
||||||
|
@ -563,7 +656,7 @@ public class CPathEntryManager {
|
||||||
if (output != null && output.isEmpty()) {
|
if (output != null && output.isEmpty()) {
|
||||||
element.setAttribute(ATTRIBUTE_OUTPUT, output.toString());
|
element.setAttribute(ATTRIBUTE_OUTPUT, output.toString());
|
||||||
}
|
}
|
||||||
} else if (kind == ICPathEntry.CDT_LIBRARY) {
|
} else if (kind == IPathEntry.CDT_LIBRARY) {
|
||||||
ILibraryEntry lib = (ILibraryEntry) entries[i];
|
ILibraryEntry lib = (ILibraryEntry) entries[i];
|
||||||
IPath path = lib.getLibraryPath();
|
IPath path = lib.getLibraryPath();
|
||||||
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
||||||
|
@ -576,11 +669,11 @@ public class CPathEntryManager {
|
||||||
if (lib.getSourceAttachmentPrefixMapping() != null) {
|
if (lib.getSourceAttachmentPrefixMapping() != null) {
|
||||||
element.setAttribute(ATTRIBUTE_PREFIXMAPPING, lib.getSourceAttachmentPrefixMapping().toString());
|
element.setAttribute(ATTRIBUTE_PREFIXMAPPING, lib.getSourceAttachmentPrefixMapping().toString());
|
||||||
}
|
}
|
||||||
} else if (kind == ICPathEntry.CDT_PROJECT) {
|
} else if (kind == IPathEntry.CDT_PROJECT) {
|
||||||
IProjectEntry pentry = (IProjectEntry) entries[i];
|
IProjectEntry pentry = (IProjectEntry) entries[i];
|
||||||
IPath path = pentry.getProjectPath();
|
IPath path = pentry.getProjectPath();
|
||||||
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
||||||
} else if (kind == ICPathEntry.CDT_INCLUDE) {
|
} else if (kind == IPathEntry.CDT_INCLUDE) {
|
||||||
IIncludeEntry include = (IIncludeEntry) entries[i];
|
IIncludeEntry include = (IIncludeEntry) entries[i];
|
||||||
IPath path = include.getResourcePath();
|
IPath path = include.getResourcePath();
|
||||||
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
||||||
|
@ -589,15 +682,15 @@ public class CPathEntryManager {
|
||||||
if (include.isSystemInclude()) {
|
if (include.isSystemInclude()) {
|
||||||
element.setAttribute(ATTRIBUTE_SYSTEM, VALUE_TRUE);
|
element.setAttribute(ATTRIBUTE_SYSTEM, VALUE_TRUE);
|
||||||
}
|
}
|
||||||
} else if (kind == ICPathEntry.CDT_MACRO) {
|
} else if (kind == IPathEntry.CDT_MACRO) {
|
||||||
IMacroEntry macro = (IMacroEntry) entries[i];
|
IMacroEntry macro = (IMacroEntry) entries[i];
|
||||||
IPath path = macro.getResourcePath();
|
IPath path = macro.getResourcePath();
|
||||||
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
element.setAttribute(ATTRIBUTE_PATH, path.toString());
|
||||||
element.setAttribute(ATTRIBUTE_NAME, macro.getMacroName());
|
element.setAttribute(ATTRIBUTE_NAME, macro.getMacroName());
|
||||||
element.setAttribute(ATTRIBUTE_VALUE, macro.getMacroValue());
|
element.setAttribute(ATTRIBUTE_VALUE, macro.getMacroValue());
|
||||||
} else if (kind == ICPathEntry.CDT_CONTAINER) {
|
} else if (kind == IPathEntry.CDT_CONTAINER) {
|
||||||
IContainerEntry container = (IContainerEntry) entries[i];
|
IContainerEntry container = (IContainerEntry) entries[i];
|
||||||
element.setAttribute(ATTRIBUTE_ID, container.getId());
|
element.setAttribute(ATTRIBUTE_ID, container.getPath().toString());
|
||||||
}
|
}
|
||||||
if (entries[i].isExported()) {
|
if (entries[i].isExported()) {
|
||||||
element.setAttribute(ATTRIBUTE_EXPORTED, VALUE_TRUE);
|
element.setAttribute(ATTRIBUTE_EXPORTED, VALUE_TRUE);
|
|
@ -16,7 +16,7 @@ import org.eclipse.cdt.core.model.IProjectEntry;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
|
|
||||||
public class ProjectEntry extends CPathEntry implements IProjectEntry {
|
public class ProjectEntry extends PathEntry implements IProjectEntry {
|
||||||
|
|
||||||
IPath projectPath;
|
IPath projectPath;
|
||||||
|
|
||||||
|
|
|
@ -1,221 +0,0 @@
|
||||||
/**********************************************************************
|
|
||||||
* Created on Mar 25, 2003
|
|
||||||
*
|
|
||||||
* Copyright (c) 2002,2003 QNX Software Systems Ltd. and others.
|
|
||||||
* All rights reserved. This program and the accompanying materials
|
|
||||||
* are made available under the terms of the Common Public License v0.5
|
|
||||||
* which accompanies this distribution, and is available at
|
|
||||||
* http://www.eclipse.org/legal/cpl-v05.html
|
|
||||||
*
|
|
||||||
* Contributors:
|
|
||||||
* QNX Software Systems - Initial API and implementation
|
|
||||||
***********************************************************************/
|
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.model;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
|
||||||
import org.eclipse.cdt.core.ICDescriptor;
|
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
|
||||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
|
||||||
import org.eclipse.cdt.core.model.ICPathEntry;
|
|
||||||
import org.eclipse.cdt.core.model.IContainerEntry;
|
|
||||||
import org.eclipse.cdt.core.model.IIncludeEntry;
|
|
||||||
import org.eclipse.cdt.core.model.IMacroEntry;
|
|
||||||
import org.eclipse.cdt.core.model.ISourceEntry;
|
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
import org.eclipse.core.resources.IProjectDescription;
|
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
import org.eclipse.core.runtime.IPath;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.Node;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public class SetCPathEntriesOperation extends CModelOperation {
|
|
||||||
|
|
||||||
ICPathEntry[] oldEntries;
|
|
||||||
ICPathEntry[] newEntries;
|
|
||||||
CProject project;
|
|
||||||
|
|
||||||
public SetCPathEntriesOperation(CProject project, ICPathEntry[] oldEntries, ICPathEntry[] newEntries) {
|
|
||||||
super(project);
|
|
||||||
this.oldEntries = oldEntries;
|
|
||||||
this.newEntries = newEntries;
|
|
||||||
this.project = project;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.cdt.internal.core.model.CModelOperation#executeOperation()
|
|
||||||
*/
|
|
||||||
protected void executeOperation() throws CModelException {
|
|
||||||
// project reference updated - may throw an exception if unable to write .cdtproject file
|
|
||||||
updateProjectReferencesIfNecessary();
|
|
||||||
try {
|
|
||||||
|
|
||||||
ICDescriptor descriptor = CCorePlugin.getDefault().getCProjectDescription(project.getProject());
|
|
||||||
Element rootElement = descriptor.getProjectData(CProject.PATH_ENTRY_ID);
|
|
||||||
// Clear out all current children
|
|
||||||
Node child = rootElement.getFirstChild();
|
|
||||||
while (child != null) {
|
|
||||||
rootElement.removeChild(child);
|
|
||||||
child = rootElement.getFirstChild();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the entries
|
|
||||||
if (newEntries != null && newEntries.length > 0) {
|
|
||||||
// Serialize the include paths
|
|
||||||
Document doc = rootElement.getOwnerDocument();
|
|
||||||
project.encodeCPathEntries(doc, rootElement, newEntries);
|
|
||||||
descriptor.saveProjectData();
|
|
||||||
}
|
|
||||||
|
|
||||||
generateCPathEntryDeltas();
|
|
||||||
done();
|
|
||||||
} catch (CoreException e) {
|
|
||||||
throw new CModelException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void updateProjectReferencesIfNecessary() throws CModelException {
|
|
||||||
String[] oldRequired = this.project.projectPrerequisites(oldEntries);
|
|
||||||
String[] newRequired = this.project.projectPrerequisites(newEntries);
|
|
||||||
|
|
||||||
try {
|
|
||||||
IProject projectResource = project.getProject();
|
|
||||||
IProjectDescription description = projectResource.getDescription();
|
|
||||||
|
|
||||||
IProject[] projectReferences = description.getReferencedProjects();
|
|
||||||
|
|
||||||
HashSet oldReferences = new HashSet(projectReferences.length);
|
|
||||||
for (int i = 0; i < projectReferences.length; i++) {
|
|
||||||
String projectName = projectReferences[i].getName();
|
|
||||||
oldReferences.add(projectName);
|
|
||||||
}
|
|
||||||
HashSet newReferences = (HashSet) oldReferences.clone();
|
|
||||||
|
|
||||||
for (int i = 0; i < oldRequired.length; i++) {
|
|
||||||
String projectName = oldRequired[i];
|
|
||||||
newReferences.remove(projectName);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < newRequired.length; i++) {
|
|
||||||
String projectName = newRequired[i];
|
|
||||||
newReferences.add(projectName);
|
|
||||||
}
|
|
||||||
|
|
||||||
Iterator iter;
|
|
||||||
int newSize = newReferences.size();
|
|
||||||
|
|
||||||
checkIdentity : {
|
|
||||||
if (oldReferences.size() == newSize) {
|
|
||||||
iter = newReferences.iterator();
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
if (!oldReferences.contains(iter.next())) {
|
|
||||||
break checkIdentity;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String[] requiredProjectNames = new String[newSize];
|
|
||||||
int index = 0;
|
|
||||||
iter = newReferences.iterator();
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
requiredProjectNames[index++] = (String) iter.next();
|
|
||||||
}
|
|
||||||
Arrays.sort(requiredProjectNames); // ensure that if changed, the order is consistent
|
|
||||||
|
|
||||||
IProject[] requiredProjectArray = new IProject[newSize];
|
|
||||||
IWorkspaceRoot wksRoot = projectResource.getWorkspace().getRoot();
|
|
||||||
for (int i = 0; i < newSize; i++) {
|
|
||||||
requiredProjectArray[i] = wksRoot.getProject(requiredProjectNames[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
description.setReferencedProjects(requiredProjectArray);
|
|
||||||
projectResource.setDescription(description, this.fMonitor);
|
|
||||||
|
|
||||||
} catch (CoreException e) {
|
|
||||||
throw new CModelException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void generateCPathEntryDeltas() {
|
|
||||||
CModelManager manager = CModelManager.getDefault();
|
|
||||||
boolean needToUpdateDependents = false;
|
|
||||||
CElementDelta delta = new CElementDelta(getCModel());
|
|
||||||
boolean hasDelta = false;
|
|
||||||
|
|
||||||
// Check the removed entries.
|
|
||||||
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) {
|
|
||||||
addCPathEntryDeltas(oldEntries[i], ICElementDelta.F_REMOVED_FROM_CPATHENTRY, delta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Check the new entries.
|
|
||||||
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) {
|
|
||||||
addCPathEntryDeltas(newEntries[i], ICElementDelta.F_ADDED_TO_CPATHENTRY, delta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds deltas, with the specified change flag.
|
|
||||||
*/
|
|
||||||
protected void addCPathEntryDeltas(ICPathEntry entry, int flag, CElementDelta delta) {
|
|
||||||
|
|
||||||
int kind = entry.getEntryKind();
|
|
||||||
ICElement celement = null;
|
|
||||||
if (kind == ICPathEntry.CDT_SOURCE) {
|
|
||||||
ISourceEntry source = (ISourceEntry) entry;
|
|
||||||
IPath path = source.getSourcePath();
|
|
||||||
celement = CoreModel.getDefault().create(path);
|
|
||||||
} else if (kind == ICPathEntry.CDT_LIBRARY) {
|
|
||||||
//ILibraryEntry lib = (ILibraryEntry) entry;
|
|
||||||
//IPath path = lib.getLibraryPath();
|
|
||||||
celement = project;
|
|
||||||
} else if (kind == ICPathEntry.CDT_PROJECT) {
|
|
||||||
//IProjectEntry pentry = (IProjectEntry) entry;
|
|
||||||
//IPath path = pentry.getProjectPath();
|
|
||||||
celement = project;
|
|
||||||
} else if (kind == ICPathEntry.CDT_INCLUDE) {
|
|
||||||
IIncludeEntry include = (IIncludeEntry) entry;
|
|
||||||
IPath path = include.getResourcePath();
|
|
||||||
celement = CoreModel.getDefault().create(path);
|
|
||||||
} else if (kind == ICPathEntry.CDT_MACRO) {
|
|
||||||
IMacroEntry macro = (IMacroEntry) entry;
|
|
||||||
IPath path = macro.getResourcePath();
|
|
||||||
celement = CoreModel.getDefault().create(path);
|
|
||||||
} else if (kind == ICPathEntry.CDT_CONTAINER) {
|
|
||||||
IContainerEntry container = (IContainerEntry) entry;
|
|
||||||
celement = project;
|
|
||||||
}
|
|
||||||
if (celement != null) {
|
|
||||||
delta.changed(celement, flag);
|
|
||||||
addDelta(delta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,126 @@
|
||||||
|
/**********************************************************************
|
||||||
|
* Created on Mar 25, 2003
|
||||||
|
*
|
||||||
|
* Copyright (c) 2002,2003 QNX Software Systems Ltd. and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Common Public License v0.5
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/cpl-v05.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* QNX Software Systems - Initial API and implementation
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.internal.core.model;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
|
import org.eclipse.cdt.core.model.IPathEntry;
|
||||||
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IProjectDescription;
|
||||||
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*/
|
||||||
|
public class SetPathEntriesOperation extends CModelOperation {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An empty array of strings indicating that a project doesn't have any prerequesite projects.
|
||||||
|
*/
|
||||||
|
static final String[] NO_PREREQUISITES = new String[0];
|
||||||
|
|
||||||
|
IPathEntry[] oldEntries;
|
||||||
|
IPathEntry[] newEntries;
|
||||||
|
ICProject cproject;
|
||||||
|
|
||||||
|
public SetPathEntriesOperation(ICProject project, IPathEntry[] oldEntries, IPathEntry[] newEntries) {
|
||||||
|
super(project);
|
||||||
|
this.oldEntries = oldEntries;
|
||||||
|
this.newEntries = newEntries;
|
||||||
|
this.cproject = project;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.core.model.CModelOperation#executeOperation()
|
||||||
|
*/
|
||||||
|
protected void executeOperation() throws CModelException {
|
||||||
|
// project reference updated - may throw an exception if unable to write .cdtproject file
|
||||||
|
updateProjectReferencesIfNecessary();
|
||||||
|
PathEntryManager mgr = PathEntryManager.getDefault();
|
||||||
|
ICElementDelta[] deltas = mgr.saveRawPathEntries(cproject, oldEntries, newEntries);
|
||||||
|
for (int i = 0; i < deltas.length; i++) {
|
||||||
|
addDelta(deltas[i]);
|
||||||
|
}
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void updateProjectReferencesIfNecessary() throws CModelException {
|
||||||
|
PathEntryManager mgr = PathEntryManager.getDefault();
|
||||||
|
String[] oldRequired = mgr.projectPrerequisites(oldEntries);
|
||||||
|
String[] newRequired = mgr.projectPrerequisites(newEntries);
|
||||||
|
|
||||||
|
try {
|
||||||
|
IProject projectResource = cproject.getProject();
|
||||||
|
IProjectDescription description = projectResource.getDescription();
|
||||||
|
|
||||||
|
IProject[] projectReferences = description.getReferencedProjects();
|
||||||
|
|
||||||
|
HashSet oldReferences = new HashSet(projectReferences.length);
|
||||||
|
for (int i = 0; i < projectReferences.length; i++) {
|
||||||
|
String projectName = projectReferences[i].getName();
|
||||||
|
oldReferences.add(projectName);
|
||||||
|
}
|
||||||
|
HashSet newReferences = (HashSet) oldReferences.clone();
|
||||||
|
|
||||||
|
for (int i = 0; i < oldRequired.length; i++) {
|
||||||
|
String projectName = oldRequired[i];
|
||||||
|
newReferences.remove(projectName);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < newRequired.length; i++) {
|
||||||
|
String projectName = newRequired[i];
|
||||||
|
newReferences.add(projectName);
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator iter;
|
||||||
|
int newSize = newReferences.size();
|
||||||
|
|
||||||
|
checkIdentity : {
|
||||||
|
if (oldReferences.size() == newSize) {
|
||||||
|
iter = newReferences.iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
if (!oldReferences.contains(iter.next())) {
|
||||||
|
break checkIdentity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String[] requiredProjectNames = new String[newSize];
|
||||||
|
int index = 0;
|
||||||
|
iter = newReferences.iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
requiredProjectNames[index++] = (String) iter.next();
|
||||||
|
}
|
||||||
|
Arrays.sort(requiredProjectNames); // ensure that if changed, the order is consistent
|
||||||
|
|
||||||
|
IProject[] requiredProjectArray = new IProject[newSize];
|
||||||
|
IWorkspaceRoot wksRoot = projectResource.getWorkspace().getRoot();
|
||||||
|
for (int i = 0; i < newSize; i++) {
|
||||||
|
requiredProjectArray[i] = wksRoot.getProject(requiredProjectNames[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
description.setReferencedProjects(requiredProjectArray);
|
||||||
|
projectResource.setDescription(description, this.fMonitor);
|
||||||
|
|
||||||
|
} catch (CoreException e) {
|
||||||
|
throw new CModelException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -15,7 +15,7 @@ package org.eclipse.cdt.internal.core.model;
|
||||||
import org.eclipse.cdt.core.model.ISourceEntry;
|
import org.eclipse.cdt.core.model.ISourceEntry;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public class SourceEntry extends ACPathEntry implements ISourceEntry {
|
public class SourceEntry extends APathEntry implements ISourceEntry {
|
||||||
|
|
||||||
IPath sourcePath;
|
IPath sourcePath;
|
||||||
IPath outputLocation;
|
IPath outputLocation;
|
||||||
|
|
Loading…
Add table
Reference in a new issue