From 0aa20e710b96622b9e2b1fb0905ceb32c6622d52 Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Thu, 22 Apr 2004 04:25:33 +0000 Subject: [PATCH] Add support for Base Reference in the PathEntry --- core/org.eclipse.cdt.core.tests/ChangeLog | 4 + .../cdt/core/model/tests/CPathEntryTest.java | 18 +- core/org.eclipse.cdt.core/ChangeLog | 18 ++ .../org/eclipse/cdt/core/model/CoreModel.java | 232 ++++++++---------- .../eclipse/cdt/core/model/IIncludeEntry.java | 7 + .../eclipse/cdt/core/model/ILibraryEntry.java | 7 + .../eclipse/cdt/core/model/IMacroEntry.java | 6 + .../eclipse/cdt/core/model/IPathEntry.java | 4 + .../cdt/internal/core/model/APathEntry.java | 31 ++- .../cdt/internal/core/model/IncludeEntry.java | 4 +- .../cdt/internal/core/model/LibraryEntry.java | 14 +- .../cdt/internal/core/model/MacroEntry.java | 4 +- .../cdt/internal/core/model/OutputEntry.java | 3 +- .../internal/core/model/PathEntryManager.java | 140 ++++++----- .../cdt/internal/core/model/SourceEntry.java | 9 +- .../ui/dialogs/cpaths/CPListElement.java | 18 +- 16 files changed, 281 insertions(+), 238 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/ChangeLog b/core/org.eclipse.cdt.core.tests/ChangeLog index f91253f2c5b..acc7fd3e30f 100644 --- a/core/org.eclipse.cdt.core.tests/ChangeLog +++ b/core/org.eclipse.cdt.core.tests/ChangeLog @@ -1,3 +1,7 @@ +2004-04-21 Alain Magloire + Update the PathEntry test. + * model/org/eclipse/cdt/core/model/tests/CPatEntryTest.java + 2004-04-21 John Camelon Moved testBug39703() from ASTFailedTests to QuickParseASTTest. Added ScannerTestCase::testBug39698(). diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CPathEntryTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CPathEntryTest.java index 2a4c523af87..aa6a99097ae 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CPathEntryTest.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CPathEntryTest.java @@ -144,9 +144,9 @@ public class CPathEntryTest extends TestCase { // 2) the default outputEntry becomes the project assertTrue("No cpathentries", entries.length == 2); entries = new IPathEntry[3]; - entries[0] = CoreModel.newIncludeEntry(new Path(""), new Path("/usr/include"), true); - entries[1] = CoreModel.newIncludeEntry(new Path("cpaththest/foo.c"), new Path("/usr/include"), true); - entries[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null); + entries[0] = CoreModel.newIncludeEntry(new Path(""), null, new Path("/usr/include"), true); + entries[1] = CoreModel.newIncludeEntry(new Path("cpaththest/foo.c"), null, new Path("/usr/include"), true); + entries[2] = CoreModel.newLibraryEntry(null, new Path("/usr/lib/libc.so.1"), null, null, null, false); testProject.setRawPathEntries(entries, new NullProgressMonitor()); entries = testProject.getResolvedPathEntries(); // We always have at least two entries: @@ -169,9 +169,9 @@ public class CPathEntryTest extends TestCase { } CProjectHelper.addCContainer(testProject, "foo"); IPathEntry[] entries = new IPathEntry[3]; - entries[0] = CoreModel.newIncludeEntry(new Path(""), new Path("/usr/include"), true); - entries[1] = CoreModel.newIncludeEntry(new Path("foo"), new Path("/usr/include"), true); - entries[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null); + entries[0] = CoreModel.newIncludeEntry(new Path(""), null, new Path("/usr/include"), true); + entries[1] = CoreModel.newIncludeEntry(new Path("foo"), null, new Path("/usr/include"), true); + entries[2] = CoreModel.newLibraryEntry(null, new Path("/usr/lib/libc.so.1"), null, null, null, false); CElementListener listener = new CElementListener(); CoreModel.getDefault().addElementChangedListener(listener); testProject.setRawPathEntries(entries, new NullProgressMonitor()); @@ -196,9 +196,9 @@ public class CPathEntryTest extends TestCase { public IPathEntry[] getPathEntries() { IPathEntry[] entries = new IPathEntry[3]; - entries[0] = CoreModel.newIncludeEntry(new Path(""), new Path("/usr/include"), true); - entries[1] = CoreModel.newIncludeEntry(new Path("foo.c"), new Path("/usr/include"), true); - entries[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null); + entries[0] = CoreModel.newIncludeEntry(new Path(""), null, new Path("/usr/include"), true); + entries[1] = CoreModel.newIncludeEntry(new Path("foo.c"), null, new Path("/usr/include"), true); + entries[2] = CoreModel.newLibraryEntry(null, new Path("/usr/lib/libc.so.1"), null, null, null, true); return entries; } diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog index d7bbc069dec..f988d863242 100644 --- a/core/org.eclipse.cdt.core/ChangeLog +++ b/core/org.eclipse.cdt.core/ChangeLog @@ -1,3 +1,21 @@ +2004-04-21 Alain Magloire + + Added support for Base Reference Attribute in the PathEntry + + * model/org/eclipse/cdt/core/model/CoreModel.java + * model/org/eclipse/cdt/core/model/IncludeEntry.java + * model/org/eclipse/cdt/core/model/ILibraryEntry.java + * model/org/eclipse/cdt/core/model/IMacroEntry.java + * model/org/eclipse/cdt/core/model/IPathEntry.java + + * model/org/eclipse/cdt/internal/core/model/APathEntry.java + * model/org/eclipse/cdt/internal/core/model/IncludeEntry.java + * model/org/eclipse/cdt/internal/core/model/LibraryEntry.java + * model/org/eclipse/cdt/internal/core/model/MacroEntry.java + * model/org/eclipse/cdt/internal/core/model/OutputEntry.java + * model/org/eclipse/cdt/internal/core/model/PathEntry.java + * model/org/eclipse/cdt/internal/core/model/SourceEntry.java + 2004-04-20 David Inglis Fixed up some small bugs with the macro paths diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java index a3f6c61ee9b..fb6c9996fc3 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java @@ -196,7 +196,7 @@ public class CoreModel { * for the project identified by the given absolute path. *

* A project entry is used to denote a prerequisite project. The - * IPathEntry[] entries of the project will be contributed. + * exported IPathEntry[] entries of the project will be contributed. *

* The prerequisite project is referred to using an absolute path relative * to the workspace root. @@ -205,19 +205,19 @@ public class CoreModel { * is equivalent to newProjectEntry(path,false). *

* - * @param path - * the absolute path of the binary archive + * @param projectPath + * the workspace-relative path of the project * @return a new project entry * * @see CoreModel#newProjectEntry(IPath, boolean) */ - public static IProjectEntry newProjectEntry(IPath path) { - return newProjectEntry(path, false); + public static IProjectEntry newProjectEntry(IPath projectPath) { + return newProjectEntry(projectPath, false); } /** * Creates and returns a new entry of kind CDT_PROJECT for - * the project identified by the given absolute path. + * the project identified by the given workspace-relative path. *

* A project entry is used to denote a prerequisite project. All the * IPathEntries of the project will be contributed as a whole. The @@ -225,15 +225,15 @@ public class CoreModel { * the workspace root. *

* - * @param path - * the absolute path of the prerequisite project + * @param projectPath + * the absolute workspace-relative path of the prerequisite project * @param isExported * indicates whether this entry is contributed to dependent - * projects in addition to the output location + * projects * @return a new project entry */ - public static IProjectEntry newProjectEntry(IPath path, boolean isExported) { - return new ProjectEntry(path, isExported); + public static IProjectEntry newProjectEntry(IPath projectPath, boolean isExported) { + return new ProjectEntry(projectPath, isExported); } /** @@ -270,60 +270,48 @@ public class CoreModel { } /** - * Creates and returns a new non-exported entry of kind CDT_LIBRARY + * Creates and returns a new entry of kind CDT_LIBRARY * 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. *

- * The resulting entry is not exported to dependent projects. This method - * is equivalent to newLibraryEntry(-,-,-,false). - *

* - * @param path - * the absolute path of the library + * @param basePath + * the base path of the library + * @param libraryPath + * the path of the library * @param sourceAttachmentPath - * the absolute path of the corresponding source archive or + * the project-relative path of the corresponding source archive or * folder, or null if none. * @param sourceAttachmentRootPath * the location of the root within the source archive or folder * or null. * @param sourceAttachmentPrefixMapping * prefix mapping or null. + * @param isExported + * whether the entry is exported * @return a new library entry * */ - public static ILibraryEntry newLibraryEntry(IPath libraryPath, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, - IPath sourceAttachmentPrefixMapping) { - return newLibraryEntry(libraryPath, null, sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping, false); + public static ILibraryEntry newLibraryEntry(IPath basePath, IPath libraryPath, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, + IPath sourceAttachmentPrefixMapping, boolean isExported) { + return new LibraryEntry(basePath, null, libraryPath, sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping, isExported); } /** - * Creates and returns a new non-exported entry of kind CDT_LIBRARY + * Creates and returns a new entry of kind CDT_LIBRARY * 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. - *

- * - * @param path - * the path of the library - * @param path - * the base path of the library - * @param sourceAttachmentPath - * the absolute path of the corresponding source archive or - * folder, or null if none. - * @param sourceAttachmentRootPath - * the location of the root within the source archive or folder - * or null. - * @param sourceAttachmentPrefixMapping - * prefix mapping or null. + * @param baseRef + * the base reference path to find the library + * @param libraryPath + * the library name. * @return a new library entry * */ - public static ILibraryEntry newLibraryEntry(IPath libraryPath, IPath basePath, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, - IPath sourceAttachmentPrefixMapping, boolean isExported) { - return new LibraryEntry(libraryPath, basePath, sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping, isExported); + public static ILibraryEntry newLibraryRefEntry(IPath baseRef, IPath libraryPath) { + return new LibraryEntry(null, baseRef, libraryPath, null, null, null, false); } /** @@ -331,28 +319,28 @@ public class CoreModel { * the project's output folder *

* - * @param path - * the project-relative path of a binary folder + * @param outputPath + * the project-relative path of a folder * @return a new source entry with not exclusion patterns * */ - public static IOutputEntry newOutputEntry(IPath path) { - return newOutputEntry(path, OutputEntry.NO_EXCLUSION_PATTERNS); + public static IOutputEntry newOutputEntry(IPath outputPath) { + return newOutputEntry(outputPath, OutputEntry.NO_EXCLUSION_PATTERNS); } /** * Creates and returns a new entry of kind CDT_OUPUT for * the project * - * @param path - * the absolute project-relative path of a binary folder + * @param outputPath + * the project-relative path of a folder * @param exclusionPatterns * the possibly empty list of exclusion patterns represented as * relative paths * @return a new source entry with the given exclusion patterns */ - public static IOutputEntry newOutputEntry(IPath path, IPath[] exclusionPatterns) { - return new OutputEntry(path, exclusionPatterns, false); + public static IOutputEntry newOutputEntry(IPath outputPath, IPath[] exclusionPatterns) { + return new OutputEntry(outputPath, exclusionPatterns, false); } /** @@ -373,13 +361,13 @@ public class CoreModel { * Particular source entries cannot be selectively exported. *

* - * @param path + * @param sourcePath * the project-relative path of a source folder * @return a new source entry with not exclusion patterns * */ - public static ISourceEntry newSourceEntry(IPath path) { - return newSourceEntry(path, SourceEntry.NO_EXCLUSION_PATTERNS); + public static ISourceEntry newSourceEntry(IPath sourcePath) { + return newSourceEntry(sourcePath, SourceEntry.NO_EXCLUSION_PATTERNS); } /** @@ -396,61 +384,56 @@ public class CoreModel { * P1. *

* - * @param path - * the absolute workspace-relative path of a source folder + * @param sourcePath + * the absolute project-relative path of a source folder * @param exclusionPatterns * the possibly empty list of exclusion patterns represented as * relative paths * @return a new source entry with the given exclusion patterns */ - public static ISourceEntry newSourceEntry(IPath path, IPath[] exclusionPatterns) { - return new SourceEntry(path, exclusionPatterns); + public static ISourceEntry newSourceEntry(IPath sourcePath, IPath[] exclusionPatterns) { + return new SourceEntry(sourcePath, exclusionPatterns); } /** * Creates and returns a new entry of kind CDT_INCLUDE * - * @param includePath - * the absolute path of the include - * @return IIncludeEntry - */ - public static IIncludeEntry newIncludeEntry(IPath includePath) { - return newIncludeEntry(null, includePath); - } - - /** - * Creates and returns a new entry of kind CDT_INCLUDE - * - * @param path + * @param resourcePath * the affected project-relative resource path + * @param basePath + * the base path of the includePath * @param includePath * the absolute path of the include * @return IIncludeEntry */ - public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath includePath) { - return newIncludeEntry(resourcePath, includePath, false); + public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath basePath, IPath includePath) { + return newIncludeEntry(resourcePath, basePath, includePath, false); } /** * * Creates and returns a new entry of kind CDT_INCLUDE * - * @param path + * @param resourcePath * the affected project-relative resource path + * @param basePath + * the base path of the includePath * @param includePath * the absolute path of the include * @param isSystemInclude * whether this include path should be consider a system include path * @return IIncludeEntry */ - public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath includePath, boolean isSystemInclude) { - return newIncludeEntry(resourcePath, includePath, isSystemInclude, IncludeEntry.NO_EXCLUSION_PATTERNS); + public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath basePath, IPath includePath, boolean isSystemInclude) { + return newIncludeEntry(resourcePath, basePath, includePath, isSystemInclude, IncludeEntry.NO_EXCLUSION_PATTERNS); } /** * Creates and returns a new entry of kind CDT_INCLUDE * - * @param path + * @param resoourcePath * the affected project-relative resource path + * @param basePath + * the base path of the includePath * @param includePath * the absolute path of the include * @param isSystemInclude @@ -460,43 +443,19 @@ public class CoreModel { * exclusion patterns in the resource if a container * @return IIincludeEntry */ - public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath includePath, boolean isSystemInclude, IPath[] exclusionPathterns) { - return newIncludeEntry(resourcePath, includePath, null, isSystemInclude, exclusionPathterns); - } - - /** - * Creates and returns a new entry of kind CDT_INCLUDE - * - * @param path - * the affected project-relative resource path - * @param includePath - * the path of the include - * @param basePath - * the base path of the include - * @param isSystemInclude - * wheter this include path should be consider the system - * include path - * @param isRecursive - * if the resource is a folder the include applied to all - * recursively - * @param exclusionPatterns - * exclusion patterns in the resource if a container - * @return IIincludeEntry - */ - public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath includePath, IPath basePath, boolean isSystemInclude, - IPath[] exclusionPatterns) { - return newIncludeEntry(resourcePath, includePath, basePath, isSystemInclude, exclusionPatterns, resourcePath == null || resourcePath.isEmpty()); + public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath basePath, IPath includePath, boolean isSystemInclude, IPath[] exclusionPathterns) { + return newIncludeEntry(resourcePath, basePath, includePath, isSystemInclude, exclusionPathterns, false); } /** * Creates and returns a new entry of kind CDT_INCLUDE * - * @param path + * @param resourcePath * the affected project-relative resource path - * @param includePath - * the path of the include * @param basePath * the base path of the include + * @param includePath + * the path of the include * @param isSystemInclude * wheter this include path should be consider the system * include path @@ -506,44 +465,31 @@ public class CoreModel { * if the entry ix exported to reference projects * @return IIincludeEntry */ - public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath includePath, IPath basePath, boolean isSystemInclude, + public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath basePath, IPath includePath, boolean isSystemInclude, IPath[] exclusionPatterns, boolean isExported) { - return new IncludeEntry(resourcePath, includePath, basePath, isSystemInclude, exclusionPatterns, isExported); + return new IncludeEntry(resourcePath, basePath, null, includePath, isSystemInclude, exclusionPatterns, isExported); } /** - * Creates and returns an entry kind CDT_MACRO + * Creates and returns a new entry of kind CDT_INCLUDE * - * @param macroName - * the name of the macro - * @param macroValue - * the value of the macro - * @return + * @param resourcePath + * the affected project-relative resource path + * @param baseRef + * the base reference path of the include + * @param includePath + * the path of the include + * @return IIincludeEntry */ - public static IMacroEntry newMacroEntry(String macroName, String macroValue) { - return newMacroEntry(null, macroName, macroValue); + public static IIncludeEntry newIncludeRefEntry(IPath resourcePath, IPath baseRef, IPath includePath) { + return new IncludeEntry(resourcePath, null, baseRef, includePath, false, null, false); } /** * Creates and returns an entry kind CDT_MACRO * * @param path - * the affected workspace-relative resource path - * @param macroName - * the name of the macro - * @param macroValue - * the value of the macro - * @return - */ - public static IMacroEntry newMacroEntry(IPath basePath, String macroName) { - return newMacroEntry(null, basePath, macroName, null, MacroEntry.NO_EXCLUSION_PATTERNS); - } - - /** - * Creates and returns an entry kind CDT_MACRO - * - * @param path - * the affected workspace-relative resource path + * the affected project-relative resource path * @param macroName * the name of the macro * @param macroValue @@ -557,8 +503,8 @@ public class CoreModel { /** * Creates and returns an entry kind CDT_MACRO * - * @param path - * the affected workspace-relative resource path + * @param resourcePath + * the affected project-relative resource path * @param macroName * the name of the macro * @param macroValue @@ -568,13 +514,13 @@ public class CoreModel { * @return */ public static IMacroEntry newMacroEntry(IPath resourcePath, String macroName, String macroValue, IPath[] exclusionPatterns) { - return newMacroEntry(resourcePath, null, macroName, macroValue, exclusionPatterns); + return newMacroEntry(resourcePath, macroName, macroValue, exclusionPatterns, false); } /** * Creates and returns an entry kind CDT_MACRO * - * @param path + * @param resourcePath * the affected workspace-relative resource path * @param macroName * the name of the macro @@ -584,9 +530,25 @@ public class CoreModel { * exclusion patterns in the resource if a container * @return */ - public static IMacroEntry newMacroEntry(IPath resourcePath, IPath basePath, String macroName, String macroValue, IPath[] exclusionPatterns) { - return new MacroEntry(resourcePath, basePath, macroName, macroValue, exclusionPatterns); + public static IMacroEntry newMacroEntry(IPath resourcePath, String macroName, String macroValue, IPath[] exclusionPatterns, boolean isExported) { + return new MacroEntry(resourcePath, null, macroName, macroValue, exclusionPatterns, isExported); } + + /** + * Creates and returns an entry kind CDT_MACRO + * + * @param resourcePath + * the affected workspace-relative resource path + * @param baseRef + * the base reference path + * @param macroName + * the name of the macro + * @return + */ + public static IMacroEntry newMacroRefEntry(IPath resourcePath, IPath baseRef, String macroName) { + return new MacroEntry(resourcePath, baseRef, macroName, null, MacroEntry.NO_EXCLUSION_PATTERNS, false); + } + /** * Answers the project specific value for a given container. In case this * container path could not be resolved, then will answer null. diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IIncludeEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IIncludeEntry.java index da88abe0085..9762e465442 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IIncludeEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IIncludeEntry.java @@ -28,6 +28,13 @@ public interface IIncludeEntry extends IPathEntry { */ IPath getBasePath(); + /** + * Return the reference path + * + * @return + */ + IPath getBaseReference(); + /** * Whether or not it a system include path * @return boolean diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILibraryEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILibraryEntry.java index 3105b47e84f..f2141aeb3aa 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILibraryEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/ILibraryEntry.java @@ -63,4 +63,11 @@ public interface ILibraryEntry extends IPathEntry { */ IPath getBasePath(); + /** + * Return the base reference. + * + * @return + */ + IPath getBaseReference(); + } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMacroEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMacroEntry.java index 2578f77b164..361dabfa872 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMacroEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMacroEntry.java @@ -41,4 +41,10 @@ public interface IMacroEntry extends IPathEntry { */ IPath getBasePath(); + /** + * return the base reference + * IMacroEntry + */ + IPath getBaseReference(); + } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IPathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IPathEntry.java index 1640600e9e1..8e27bd62a0a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IPathEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IPathEntry.java @@ -84,6 +84,10 @@ public interface IPathEntry { */ boolean isExported(); + /** + * + * @return IPath + */ IPath getPath(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/APathEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/APathEntry.java index 5e7350b6b31..cedc2f4fb4b 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/APathEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/APathEntry.java @@ -13,23 +13,32 @@ package org.eclipse.cdt.internal.core.model; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; public abstract class APathEntry extends PathEntry { public static IPath[] NO_EXCLUSION_PATTERNS = {}; + public final static IPath EMPTY_PATH = new Path(""); IPath[] exclusionPatterns; IPath basePath; + IPath baseRef; private final static char[][] UNINIT_PATTERNS = new char[][] { "Non-initialized yet".toCharArray() }; //$NON-NLS-1$ char[][]fullCharExclusionPatterns = UNINIT_PATTERNS; - public APathEntry (int kind, IPath path, IPath basePath, IPath[] exclusionPatterns, boolean isExported) { + /** + * + * @param kind + * @param basePath + * @param baseRef + * @param path + * @param exclusionPatterns + * @param isExported + */ + public APathEntry (int kind, IPath basePath, IPath baseRef, IPath path, IPath[] exclusionPatterns, boolean isExported) { super(kind, path, isExported); - this.basePath = basePath; - if (exclusionPatterns == null) { - this.exclusionPatterns = NO_EXCLUSION_PATTERNS; - } else { - this.exclusionPatterns = exclusionPatterns; - } + this.basePath = (basePath == null) ? EMPTY_PATH : basePath; + this.baseRef = (baseRef == null) ? EMPTY_PATH : baseRef; + this.exclusionPatterns = (exclusionPatterns == null) ? NO_EXCLUSION_PATTERNS : exclusionPatterns; } /** @@ -48,6 +57,14 @@ public abstract class APathEntry extends PathEntry { return basePath; } + /** + * + * @return + */ + public IPath getBaseReference() { + return baseRef; + } + /** * Returns a char based representation of the exclusions patterns full path. */ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java index 60e4bcdda1a..20b91b6f016 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/IncludeEntry.java @@ -19,9 +19,9 @@ public class IncludeEntry extends APathEntry implements IIncludeEntry { IPath includePath; boolean isSystemInclude; - public IncludeEntry(IPath resourcePath, IPath includePath, IPath basePath, boolean isSystemInclude, + public IncludeEntry(IPath resourcePath, IPath basePath, IPath baseRef, IPath includePath, boolean isSystemInclude, IPath[] exclusionPatterns, boolean isExported) { - super(IIncludeEntry.CDT_INCLUDE, resourcePath, basePath, exclusionPatterns, isExported); + super(IIncludeEntry.CDT_INCLUDE, basePath, baseRef, resourcePath, exclusionPatterns, isExported); this.includePath = includePath; this.isSystemInclude = isSystemInclude; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java index a8655763617..66733791bad 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/LibraryEntry.java @@ -22,9 +22,19 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry { IPath sourceAttachmentRootPath; IPath sourceAttachmentPrefixMapping; - public LibraryEntry(IPath libraryPath, IPath basePath, IPath sourceAttachmentPath, + /** + * + * @param basePath + * @param baseRef + * @param libraryPath + * @param sourceAttachmentPath + * @param sourceAttachmentRootPath + * @param sourceAttachmentPrefixMapping + * @param isExported + */ + public LibraryEntry(IPath basePath, IPath baseRef, IPath libraryPath, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, IPath sourceAttachmentPrefixMapping, boolean isExported) { - super(ILibraryEntry.CDT_LIBRARY, libraryPath, basePath, APathEntry.NO_EXCLUSION_PATTERNS, isExported); + super(ILibraryEntry.CDT_LIBRARY, basePath, baseRef, libraryPath, APathEntry.NO_EXCLUSION_PATTERNS, isExported); this.sourceAttachmentPath = sourceAttachmentPath; this.sourceAttachmentRootPath = sourceAttachmentRootPath; this.sourceAttachmentPrefixMapping = sourceAttachmentPrefixMapping; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java index a95d5134c00..b36a223f0db 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/MacroEntry.java @@ -20,8 +20,8 @@ public class MacroEntry extends APathEntry implements IMacroEntry { String macroName; String macroValue; - public MacroEntry (IPath path, IPath basePath, String macroName, String macroValue, IPath[] exclusionPatterns) { - super(IMacroEntry.CDT_MACRO, path, basePath, exclusionPatterns, path == null); + public MacroEntry (IPath path, IPath baseRef, String macroName, String macroValue, IPath[] exclusionPatterns, boolean isExported) { + super(IMacroEntry.CDT_MACRO, null, baseRef, path, exclusionPatterns, isExported); this.macroName = macroName; this.macroValue = macroValue; } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/OutputEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/OutputEntry.java index abbfb6d4ed8..92d766dc928 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/OutputEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/OutputEntry.java @@ -20,12 +20,11 @@ public class OutputEntry extends APathEntry implements IOutputEntry { /** * @param kind * @param path - * @param isRecursive * @param exclusionPatterns * @param isExported */ public OutputEntry(IPath path, IPath[] exclusionPatterns, boolean isExported) { - super(CDT_OUTPUT, path, null, exclusionPatterns, isExported); + super(CDT_OUTPUT, null, null, path, exclusionPatterns, isExported); } public boolean equals(Object obj) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java index 7a40cd17b35..7f9c044f2ae 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/PathEntryManager.java @@ -65,7 +65,8 @@ public class PathEntryManager implements ICDescriptorListener { static String PATH_ENTRY_ID = "org.eclipse.cdt.core.pathentry"; //$NON-NLS-1$ static String ATTRIBUTE_KIND = "kind"; //$NON-NLS-1$ static String ATTRIBUTE_PATH = "path"; //$NON-NLS-1$ - static String ATTRIBUTE_BASE_PATH = "base"; //$NON-NLS-1$ + static String ATTRIBUTE_BASE_PATH = "base-path"; //$NON-NLS-1$ + static String ATTRIBUTE_BASE_REF = "base-ref"; //$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$ @@ -665,19 +666,18 @@ public class PathEntryManager implements ICDescriptorListener { isExported = element.getAttribute(ATTRIBUTE_EXPORTED).equals(VALUE_TRUE); } - // ensure path is absolute - //boolean hasPath = element.hasAttribute(ATTRIBUTE_PATH); - String pathAttr = element.getAttribute(ATTRIBUTE_PATH); - IPath path = new Path(pathAttr); + // get path and ensure it is absolute + //String pathAttr = element.getAttribute(ATTRIBUTE_PATH); + IPath path = new Path(element.getAttribute(ATTRIBUTE_PATH)); if (!path.isAbsolute()) { path = projectPath.append(path); } // check fo the base path - IPath basePath = new Path(""); //$NON-NLS-1$ - if (element.hasAttribute(ATTRIBUTE_BASE_PATH)) { - basePath = new Path(element.getAttribute(ATTRIBUTE_BASE_PATH)); - } + IPath basePath = new Path(element.getAttribute(ATTRIBUTE_BASE_PATH)); + + // get the base ref + IPath baseRef = new Path(element.getAttribute(ATTRIBUTE_BASE_REF)); // source attachment info (optional) IPath sourceAttachmentPath = element.hasAttribute(ATTRIBUTE_SOURCEPATH) ? new Path( @@ -706,8 +706,11 @@ public class PathEntryManager implements ICDescriptorListener { case IPathEntry.CDT_PROJECT : return CoreModel.newProjectEntry(path, isExported); case IPathEntry.CDT_LIBRARY : - return CoreModel.newLibraryEntry(path, basePath, sourceAttachmentPath, sourceAttachmentRootPath, - sourceAttachmentPrefixMapping, isExported); + if (!baseRef.isEmpty()) { + return CoreModel.newLibraryRefEntry(baseRef, path); + } + return CoreModel.newLibraryEntry(basePath, path, sourceAttachmentPath, sourceAttachmentRootPath, + sourceAttachmentPrefixMapping, isExported); case IPathEntry.CDT_SOURCE : { // must be an entry in this project or specify another @@ -727,21 +730,25 @@ public class PathEntryManager implements ICDescriptorListener { case IPathEntry.CDT_INCLUDE : { // include path info - IPath includePath = element.hasAttribute(ATTRIBUTE_INCLUDE) - ? new Path(element.getAttribute(ATTRIBUTE_INCLUDE)) - : null; + IPath includePath = new Path(element.getAttribute(ATTRIBUTE_INCLUDE)); // isSysteminclude boolean isSystemInclude = false; if (element.hasAttribute(ATTRIBUTE_SYSTEM)) { isSystemInclude = element.getAttribute(ATTRIBUTE_SYSTEM).equals(VALUE_TRUE); } - return CoreModel.newIncludeEntry(path, includePath, basePath, isSystemInclude, exclusionPatterns, isExported); + if (!baseRef.isEmpty()) { + return CoreModel.newIncludeRefEntry(path, baseRef, includePath); + } + return CoreModel.newIncludeEntry(path, basePath, includePath, isSystemInclude, exclusionPatterns, isExported); } case IPathEntry.CDT_MACRO : { String macroName = element.getAttribute(ATTRIBUTE_NAME); String macroValue = element.getAttribute(ATTRIBUTE_VALUE); - return CoreModel.newMacroEntry(path, basePath, macroName, macroValue, exclusionPatterns); + if (!baseRef.isEmpty()) { + return CoreModel.newMacroRefEntry(path, baseRef, macroName); + } + return CoreModel.newMacroEntry(path, macroName, macroValue, exclusionPatterns, isExported); } case IPathEntry.CDT_CONTAINER : { @@ -785,66 +792,67 @@ public class PathEntryManager implements ICDescriptorListener { } } + // Save the path + element.setAttribute(ATTRIBUTE_PATH, xmlPath.toString()); + // Specifics to the entries - if (kind == IPathEntry.CDT_SOURCE) { - element.setAttribute(ATTRIBUTE_PATH, xmlPath.toString()); - } else if (kind == IPathEntry.CDT_OUTPUT) { - element.setAttribute(ATTRIBUTE_PATH, xmlPath.toString()); - } else if (kind == IPathEntry.CDT_LIBRARY) { - ILibraryEntry lib = (ILibraryEntry) entries[i]; - element.setAttribute(ATTRIBUTE_PATH, xmlPath.toString()); - if (lib.getBasePath() != null) { - element.setAttribute(ATTRIBUTE_BASE_PATH, lib.getBasePath().toString()); - } - IPath sourcePath = lib.getSourceAttachmentPath(); - if (sourcePath != null) { - // translate to project relative from absolute - if (projectPath != null && projectPath.isPrefixOf(sourcePath)) { - if (sourcePath.segment(0).equals(projectPath.segment(0))) { - sourcePath = sourcePath.removeFirstSegments(1); - sourcePath = sourcePath.makeRelative(); + switch(kind) { + case IPathEntry.CDT_SOURCE: + case IPathEntry.CDT_OUTPUT: + case IPathEntry.CDT_PROJECT: + case IPathEntry.CDT_CONTAINER: + break; + case IPathEntry.CDT_LIBRARY: { + ILibraryEntry lib = (ILibraryEntry) entries[i]; + IPath sourcePath = lib.getSourceAttachmentPath(); + if (sourcePath != null) { + // translate to project relative from absolute + if (projectPath != null && projectPath.isPrefixOf(sourcePath)) { + if (sourcePath.segment(0).equals(projectPath.segment(0))) { + sourcePath = sourcePath.removeFirstSegments(1); + sourcePath = sourcePath.makeRelative(); + } } + element.setAttribute(ATTRIBUTE_SOURCEPATH, sourcePath.toString()); } - element.setAttribute(ATTRIBUTE_SOURCEPATH, sourcePath.toString()); + if (lib.getSourceAttachmentRootPath() != null) { + element.setAttribute(ATTRIBUTE_ROOTPATH, lib.getSourceAttachmentRootPath().toString()); + } + if (lib.getSourceAttachmentPrefixMapping() != null) { + element.setAttribute(ATTRIBUTE_PREFIXMAPPING, lib.getSourceAttachmentPrefixMapping().toString()); + } + break; } - if (lib.getSourceAttachmentRootPath() != null) { - element.setAttribute(ATTRIBUTE_ROOTPATH, lib.getSourceAttachmentRootPath().toString()); + case IPathEntry.CDT_INCLUDE: { + IIncludeEntry include = (IIncludeEntry) entries[i]; + IPath includePath = include.getIncludePath(); + element.setAttribute(ATTRIBUTE_INCLUDE, includePath.toString()); + if (include.isSystemInclude()) { + element.setAttribute(ATTRIBUTE_SYSTEM, VALUE_TRUE); + } + break; } - if (lib.getSourceAttachmentPrefixMapping() != null) { - element.setAttribute(ATTRIBUTE_PREFIXMAPPING, lib.getSourceAttachmentPrefixMapping().toString()); + case IPathEntry.CDT_MACRO: { + IMacroEntry macro = (IMacroEntry) entries[i]; + element.setAttribute(ATTRIBUTE_NAME, macro.getMacroName()); + element.setAttribute(ATTRIBUTE_VALUE, macro.getMacroValue()); + break; } - } else if (kind == IPathEntry.CDT_PROJECT) { - element.setAttribute(ATTRIBUTE_PATH, xmlPath.toString()); - } else if (kind == IPathEntry.CDT_INCLUDE) { - IIncludeEntry include = (IIncludeEntry) entries[i]; - if (!xmlPath.isEmpty()) { - element.setAttribute(ATTRIBUTE_PATH, xmlPath.toString()); - } - if (include.getBasePath() != null) { - element.setAttribute(ATTRIBUTE_BASE_PATH, include.getBasePath().toString()); - } - IPath includePath = include.getIncludePath(); - element.setAttribute(ATTRIBUTE_INCLUDE, includePath.toString()); - if (include.isSystemInclude()) { - element.setAttribute(ATTRIBUTE_SYSTEM, VALUE_TRUE); - } - } else if (kind == IPathEntry.CDT_MACRO) { - IMacroEntry macro = (IMacroEntry) entries[i]; - if (!xmlPath.isEmpty()) { - element.setAttribute(ATTRIBUTE_PATH, macro.getPath().toString()); - } - if (macro.getBasePath() != null) { - element.setAttribute(ATTRIBUTE_BASE_PATH, macro.getBasePath().toString()); - } - element.setAttribute(ATTRIBUTE_NAME, macro.getMacroName()); - element.setAttribute(ATTRIBUTE_VALUE, macro.getMacroValue()); - } else if (kind == IPathEntry.CDT_CONTAINER) { - element.setAttribute(ATTRIBUTE_PATH, xmlPath.toString()); } - // Save the exclusions attributes if (entries[i] instanceof APathEntry) { APathEntry entry = (APathEntry) entries[i]; + + // save the basePath or the baseRef + IPath basePath = entry.getBasePath(); + IPath baseRef = entry.getBaseReference(); + if (basePath != null && !basePath.isEmpty()) { + element.setAttribute(ATTRIBUTE_BASE_PATH, basePath.toString()); + } else if (baseRef != null && !baseRef.isEmpty()) { + element.setAttribute(ATTRIBUTE_BASE_REF, baseRef.toString()); + } + + // Save the exclusions attributes IPath[] exclusionPatterns = entry.getExclusionPatterns(); if (exclusionPatterns.length > 0) { StringBuffer excludeRule = new StringBuffer(10); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceEntry.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceEntry.java index 15b7b5ce653..e4e6e472cd1 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceEntry.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/SourceEntry.java @@ -17,8 +17,13 @@ import org.eclipse.core.runtime.IPath; public class SourceEntry extends APathEntry implements ISourceEntry { - public SourceEntry(IPath path, IPath[] exclusionPatterns) { - super(ISourceEntry.CDT_SOURCE, path, null, exclusionPatterns, false); + /** + * + * @param path + * @param exclusionPatterns + */ + public SourceEntry(IPath sourcePath, IPath[] exclusionPatterns) { + super(ISourceEntry.CDT_SOURCE, null, null, sourcePath, exclusionPatterns, false); } public boolean equals (Object obj) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListElement.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListElement.java index 89147f5f3c7..e12663e63df 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListElement.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dialogs/cpaths/CPListElement.java @@ -34,8 +34,8 @@ public class CPListElement { public static final String SYSTEM_INCLUDE = "systeminclude"; //$NON-NLS-1$ public static final String MACRO_NAME = "macroname"; //$NON-NLS-1$ public static final String MACRO_VALUE = "macrovalue"; //$NON-NLS-1$ - public static final String BASE_REF = "baseref"; //$NON-NLS-1$ - public static final String BASE = "base"; //$NON-NLS-1$ + public static final String BASE_REF = "base-ref"; //$NON-NLS-1$ + public static final String BASE = "base-path"; //$NON-NLS-1$ private ICProject fProject; @@ -123,25 +123,21 @@ public class CPListElement { return CoreModel.newSourceEntry(fPath, exclusionPattern); case IPathEntry.CDT_LIBRARY: IPath attach = (IPath) getAttribute(SOURCEATTACHMENT); - return CoreModel.newLibraryEntry(fPath, base, attach, null, null, isExported()); + return CoreModel.newLibraryEntry(base, fPath, attach, null, null, isExported()); case IPathEntry.CDT_PROJECT: return CoreModel.newProjectEntry(fPath, isExported()); case IPathEntry.CDT_CONTAINER: return CoreModel.newContainerEntry(fPath, isExported()); case IPathEntry.CDT_INCLUDE: if (base != null) { - return CoreModel.newIncludeEntry(fPath, (IPath) getAttribute(INCLUDE), base, + return CoreModel.newIncludeEntry(fPath, base, (IPath) getAttribute(INCLUDE), ((Boolean) getAttribute(SYSTEM_INCLUDE)).booleanValue(), exclusionPattern); } else { - + } case IPathEntry.CDT_MACRO: - if (base != null) { - return CoreModel.newMacroEntry(fPath, base, (String) getAttribute(MACRO_NAME), - (String) getAttribute(MACRO_VALUE), exclusionPattern); - } else { - - } + return CoreModel.newMacroEntry(fPath, (String) getAttribute(MACRO_NAME), + (String) getAttribute(MACRO_VALUE), exclusionPattern); default: return null; }