1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Add support for Base Reference in the PathEntry

This commit is contained in:
Alain Magloire 2004-04-22 04:25:33 +00:00
parent 03144000c4
commit 0aa20e710b
16 changed files with 281 additions and 238 deletions

View file

@ -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 2004-04-21 John Camelon
Moved testBug39703() from ASTFailedTests to QuickParseASTTest. Moved testBug39703() from ASTFailedTests to QuickParseASTTest.
Added ScannerTestCase::testBug39698(). Added ScannerTestCase::testBug39698().

View file

@ -144,9 +144,9 @@ public class CPathEntryTest extends TestCase {
// 2) the default outputEntry becomes the project // 2) the default outputEntry becomes the project
assertTrue("No cpathentries", entries.length == 2); assertTrue("No cpathentries", entries.length == 2);
entries = new IPathEntry[3]; entries = new IPathEntry[3];
entries[0] = CoreModel.newIncludeEntry(new Path(""), new Path("/usr/include"), true); entries[0] = CoreModel.newIncludeEntry(new Path(""), null, new Path("/usr/include"), true);
entries[1] = CoreModel.newIncludeEntry(new Path("cpaththest/foo.c"), new Path("/usr/include"), true); entries[1] = CoreModel.newIncludeEntry(new Path("cpaththest/foo.c"), null, new Path("/usr/include"), true);
entries[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null); entries[2] = CoreModel.newLibraryEntry(null, new Path("/usr/lib/libc.so.1"), null, null, null, false);
testProject.setRawPathEntries(entries, new NullProgressMonitor()); testProject.setRawPathEntries(entries, new NullProgressMonitor());
entries = testProject.getResolvedPathEntries(); entries = testProject.getResolvedPathEntries();
// We always have at least two entries: // We always have at least two entries:
@ -169,9 +169,9 @@ public class CPathEntryTest extends TestCase {
} }
CProjectHelper.addCContainer(testProject, "foo"); CProjectHelper.addCContainer(testProject, "foo");
IPathEntry[] entries = new IPathEntry[3]; IPathEntry[] entries = new IPathEntry[3];
entries[0] = CoreModel.newIncludeEntry(new Path(""), new Path("/usr/include"), true); entries[0] = CoreModel.newIncludeEntry(new Path(""), null, new Path("/usr/include"), true);
entries[1] = CoreModel.newIncludeEntry(new Path("foo"), new Path("/usr/include"), true); entries[1] = CoreModel.newIncludeEntry(new Path("foo"), null, new Path("/usr/include"), true);
entries[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null); entries[2] = CoreModel.newLibraryEntry(null, new Path("/usr/lib/libc.so.1"), null, null, null, false);
CElementListener listener = new CElementListener(); CElementListener listener = new CElementListener();
CoreModel.getDefault().addElementChangedListener(listener); CoreModel.getDefault().addElementChangedListener(listener);
testProject.setRawPathEntries(entries, new NullProgressMonitor()); testProject.setRawPathEntries(entries, new NullProgressMonitor());
@ -196,9 +196,9 @@ public class CPathEntryTest extends TestCase {
public IPathEntry[] getPathEntries() { public IPathEntry[] getPathEntries() {
IPathEntry[] entries = new IPathEntry[3]; IPathEntry[] entries = new IPathEntry[3];
entries[0] = CoreModel.newIncludeEntry(new Path(""), new Path("/usr/include"), true); entries[0] = CoreModel.newIncludeEntry(new Path(""), null, new Path("/usr/include"), true);
entries[1] = CoreModel.newIncludeEntry(new Path("foo.c"), new Path("/usr/include"), true); entries[1] = CoreModel.newIncludeEntry(new Path("foo.c"), null, new Path("/usr/include"), true);
entries[2] = CoreModel.newLibraryEntry(new Path("/usr/lib/libc.so.1"), null, null, null); entries[2] = CoreModel.newLibraryEntry(null, new Path("/usr/lib/libc.so.1"), null, null, null, true);
return entries; return entries;
} }

View file

@ -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 2004-04-20 David Inglis
Fixed up some small bugs with the macro paths Fixed up some small bugs with the macro paths

View file

@ -196,7 +196,7 @@ public class CoreModel {
* for the project identified by the given absolute path. * for the project identified by the given absolute path.
* <p> * <p>
* A project entry is used to denote a prerequisite project. The * 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.
* <p> * <p>
* The prerequisite project is referred to using an absolute path relative * The prerequisite project is referred to using an absolute path relative
* to the workspace root. * to the workspace root.
@ -205,19 +205,19 @@ public class CoreModel {
* is equivalent to <code>newProjectEntry(path,false)</code>. * is equivalent to <code>newProjectEntry(path,false)</code>.
* <p> * <p>
* *
* @param path * @param projectPath
* the absolute path of the binary archive * the workspace-relative path of the project
* @return a new project entry * @return a new project entry
* *
* @see CoreModel#newProjectEntry(IPath, boolean) * @see CoreModel#newProjectEntry(IPath, boolean)
*/ */
public static IProjectEntry newProjectEntry(IPath path) { public static IProjectEntry newProjectEntry(IPath projectPath) {
return newProjectEntry(path, false); return newProjectEntry(projectPath, false);
} }
/** /**
* Creates and returns a new entry of kind <code>CDT_PROJECT</code> for * Creates and returns a new entry of kind <code>CDT_PROJECT</code> for
* the project identified by the given absolute path. * the project identified by the given workspace-relative path.
* <p> * <p>
* A project entry is used to denote a prerequisite project. All the * A project entry is used to denote a prerequisite project. All the
* IPathEntries of the project will be contributed as a whole. The * IPathEntries of the project will be contributed as a whole. The
@ -225,15 +225,15 @@ public class CoreModel {
* the workspace root. * the workspace root.
* <p> * <p>
* *
* @param path * @param projectPath
* the absolute path of the prerequisite project * the absolute workspace-relative path of the prerequisite project
* @param isExported * @param isExported
* indicates whether this entry is contributed to dependent * indicates whether this entry is contributed to dependent
* projects in addition to the output location * projects
* @return a new project entry * @return a new project entry
*/ */
public static IProjectEntry newProjectEntry(IPath path, boolean isExported) { public static IProjectEntry newProjectEntry(IPath projectPath, boolean isExported) {
return new ProjectEntry(path, isExported); return new ProjectEntry(projectPath, isExported);
} }
/** /**
@ -270,60 +270,48 @@ public class CoreModel {
} }
/** /**
* Creates and returns a new non-exported entry of kind <code>CDT_LIBRARY</code> * Creates and returns a new entry of kind <code>CDT_LIBRARY</code>
* for the archive or folder identified by the 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 * Note that this operation does not attempt to validate or access the
* resources at the given paths. * 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>.
* <p>
* *
* @param path * @param basePath
* the absolute path of the library * the base path of the library
* @param libraryPath
* the path of the library
* @param sourceAttachmentPath * @param sourceAttachmentPath
* the absolute path of the corresponding source archive or * the project-relative path of the corresponding source archive or
* folder, or <code>null</code> if none. * folder, or <code>null</code> if none.
* @param sourceAttachmentRootPath * @param sourceAttachmentRootPath
* the location of the root within the source archive or folder * the location of the root within the source archive or folder
* or <code>null</code>. * or <code>null</code>.
* @param sourceAttachmentPrefixMapping * @param sourceAttachmentPrefixMapping
* prefix mapping or <code>null</code>. * prefix mapping or <code>null</code>.
* @param isExported
* whether the entry is exported
* @return a new library entry * @return a new library entry
* *
*/ */
public static ILibraryEntry newLibraryEntry(IPath libraryPath, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, public static ILibraryEntry newLibraryEntry(IPath basePath, IPath libraryPath, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath,
IPath sourceAttachmentPrefixMapping) { IPath sourceAttachmentPrefixMapping, boolean isExported) {
return newLibraryEntry(libraryPath, null, sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping, false); return new LibraryEntry(basePath, null, libraryPath, sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping, isExported);
} }
/** /**
* Creates and returns a new non-exported entry of kind <code>CDT_LIBRARY</code> * Creates and returns a new entry of kind <code>CDT_LIBRARY</code>
* for the archive or folder identified by the 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 * @param baseRef
* resources at the given paths. * the base reference path to find the library
* <p> * @param libraryPath
* * the library name.
* @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 <code>null</code> if none.
* @param sourceAttachmentRootPath
* the location of the root within the source archive or folder
* or <code>null</code>.
* @param sourceAttachmentPrefixMapping
* prefix mapping or <code>null</code>.
* @return a new library entry * @return a new library entry
* *
*/ */
public static ILibraryEntry newLibraryEntry(IPath libraryPath, IPath basePath, IPath sourceAttachmentPath, IPath sourceAttachmentRootPath, public static ILibraryEntry newLibraryRefEntry(IPath baseRef, IPath libraryPath) {
IPath sourceAttachmentPrefixMapping, boolean isExported) { return new LibraryEntry(null, baseRef, libraryPath, null, null, null, false);
return new LibraryEntry(libraryPath, basePath, sourceAttachmentPath, sourceAttachmentRootPath, sourceAttachmentPrefixMapping, isExported);
} }
/** /**
@ -331,28 +319,28 @@ public class CoreModel {
* the project's output folder * the project's output folder
* <p> * <p>
* *
* @param path * @param outputPath
* the project-relative path of a binary folder * the project-relative path of a folder
* @return a new source entry with not exclusion patterns * @return a new source entry with not exclusion patterns
* *
*/ */
public static IOutputEntry newOutputEntry(IPath path) { public static IOutputEntry newOutputEntry(IPath outputPath) {
return newOutputEntry(path, OutputEntry.NO_EXCLUSION_PATTERNS); return newOutputEntry(outputPath, OutputEntry.NO_EXCLUSION_PATTERNS);
} }
/** /**
* Creates and returns a new entry of kind <code>CDT_OUPUT</code> for * Creates and returns a new entry of kind <code>CDT_OUPUT</code> for
* the project * the project
* *
* @param path * @param outputPath
* the absolute project-relative path of a binary folder * the project-relative path of a folder
* @param exclusionPatterns * @param exclusionPatterns
* the possibly empty list of exclusion patterns represented as * the possibly empty list of exclusion patterns represented as
* relative paths * relative paths
* @return a new source entry with the given exclusion patterns * @return a new source entry with the given exclusion patterns
*/ */
public static IOutputEntry newOutputEntry(IPath path, IPath[] exclusionPatterns) { public static IOutputEntry newOutputEntry(IPath outputPath, IPath[] exclusionPatterns) {
return new OutputEntry(path, exclusionPatterns, false); return new OutputEntry(outputPath, exclusionPatterns, false);
} }
/** /**
@ -373,13 +361,13 @@ public class CoreModel {
* Particular source entries cannot be selectively exported. * Particular source entries cannot be selectively exported.
* </p> * </p>
* *
* @param path * @param sourcePath
* the project-relative path of a source folder * the project-relative path of a source folder
* @return a new source entry with not exclusion patterns * @return a new source entry with not exclusion patterns
* *
*/ */
public static ISourceEntry newSourceEntry(IPath path) { public static ISourceEntry newSourceEntry(IPath sourcePath) {
return newSourceEntry(path, SourceEntry.NO_EXCLUSION_PATTERNS); return newSourceEntry(sourcePath, SourceEntry.NO_EXCLUSION_PATTERNS);
} }
/** /**
@ -396,61 +384,56 @@ public class CoreModel {
* <code>P1</code>. * <code>P1</code>.
* </p> * </p>
* *
* @param path * @param sourcePath
* the absolute workspace-relative path of a source folder * the absolute project-relative path of a source folder
* @param exclusionPatterns * @param exclusionPatterns
* the possibly empty list of exclusion patterns represented as * the possibly empty list of exclusion patterns represented as
* relative paths * relative paths
* @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[] exclusionPatterns) { public static ISourceEntry newSourceEntry(IPath sourcePath, IPath[] exclusionPatterns) {
return new SourceEntry(path, exclusionPatterns); return new SourceEntry(sourcePath, exclusionPatterns);
} }
/** /**
* 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 includePath * @param resourcePath
* 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 <code>CDT_INCLUDE</code>
*
* @param path
* the affected project-relative resource path * the affected project-relative resource path
* @param basePath
* the base path of the includePath
* @param includePath * @param includePath
* the absolute path of the include * the absolute path of the include
* @return IIncludeEntry * @return IIncludeEntry
*/ */
public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath includePath) { public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath basePath, IPath includePath) {
return newIncludeEntry(resourcePath, includePath, false); return newIncludeEntry(resourcePath, basePath, includePath, false);
} }
/** /**
* * 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 resourcePath
* the affected project-relative resource path * the affected project-relative resource path
* @param basePath
* the base path of the includePath
* @param includePath * @param includePath
* the absolute path of the include * the absolute path of the include
* @param isSystemInclude * @param isSystemInclude
* whether this include path should be consider a system include path * whether this include path should be consider a system include path
* @return IIncludeEntry * @return IIncludeEntry
*/ */
public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath includePath, boolean isSystemInclude) { public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath basePath, IPath includePath, boolean isSystemInclude) {
return newIncludeEntry(resourcePath, includePath, isSystemInclude, IncludeEntry.NO_EXCLUSION_PATTERNS); return newIncludeEntry(resourcePath, basePath, includePath, isSystemInclude, 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 resoourcePath
* the affected project-relative resource path * the affected project-relative resource path
* @param basePath
* the base path of the includePath
* @param includePath * @param includePath
* the absolute path of the include * the absolute path of the include
* @param isSystemInclude * @param isSystemInclude
@ -460,43 +443,19 @@ public class CoreModel {
* exclusion patterns in the resource if a container * exclusion patterns in the resource if a container
* @return IIincludeEntry * @return IIincludeEntry
*/ */
public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath includePath, boolean isSystemInclude, IPath[] exclusionPathterns) { public static IIncludeEntry newIncludeEntry(IPath resourcePath, IPath basePath, IPath includePath, boolean isSystemInclude, IPath[] exclusionPathterns) {
return newIncludeEntry(resourcePath, includePath, null, isSystemInclude, exclusionPathterns); return newIncludeEntry(resourcePath, basePath, includePath, isSystemInclude, exclusionPathterns, false);
} }
/** /**
* 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 resourcePath
* the affected project-relative resource path * the affected project-relative resource path
* @param includePath
* the path of the include
* @param basePath * @param basePath
* the base path of the include * 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());
}
/**
* Creates and returns a new entry of kind <code>CDT_INCLUDE</code>
*
* @param path
* the affected project-relative resource path
* @param includePath * @param includePath
* the path of the include * the path of the include
* @param basePath
* the base path of the include
* @param isSystemInclude * @param isSystemInclude
* wheter this include path should be consider the system * wheter this include path should be consider the system
* include path * include path
@ -506,44 +465,31 @@ public class CoreModel {
* if the entry ix exported to reference projects * if the entry ix exported to reference projects
* @return IIincludeEntry * @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) { 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 <code>CDT_MACRO</code> * Creates and returns a new entry of kind <code>CDT_INCLUDE</code>
* *
* @param macroName * @param resourcePath
* the name of the macro * the affected project-relative resource path
* @param macroValue * @param baseRef
* the value of the macro * the base reference path of the include
* @return * @param includePath
* the path of the include
* @return IIincludeEntry
*/ */
public static IMacroEntry newMacroEntry(String macroName, String macroValue) { public static IIncludeEntry newIncludeRefEntry(IPath resourcePath, IPath baseRef, IPath includePath) {
return newMacroEntry(null, macroName, macroValue); return new IncludeEntry(resourcePath, null, baseRef, includePath, false, null, false);
} }
/** /**
* Creates and returns an entry kind <code>CDT_MACRO</code> * Creates and returns an entry kind <code>CDT_MACRO</code>
* *
* @param path * @param path
* the affected workspace-relative resource path * the affected project-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 <code>CDT_MACRO</code>
*
* @param path
* the affected workspace-relative resource path
* @param macroName * @param macroName
* the name of the macro * the name of the macro
* @param macroValue * @param macroValue
@ -557,8 +503,8 @@ public class CoreModel {
/** /**
* Creates and returns an entry kind <code>CDT_MACRO</code> * Creates and returns an entry kind <code>CDT_MACRO</code>
* *
* @param path * @param resourcePath
* the affected workspace-relative resource path * the affected project-relative resource path
* @param macroName * @param macroName
* the name of the macro * the name of the macro
* @param macroValue * @param macroValue
@ -568,13 +514,13 @@ public class CoreModel {
* @return * @return
*/ */
public static IMacroEntry newMacroEntry(IPath resourcePath, String macroName, String macroValue, IPath[] exclusionPatterns) { 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 <code>CDT_MACRO</code> * Creates and returns an entry kind <code>CDT_MACRO</code>
* *
* @param path * @param resourcePath
* the affected workspace-relative resource path * the affected workspace-relative resource path
* @param macroName * @param macroName
* the name of the macro * the name of the macro
@ -584,9 +530,25 @@ public class CoreModel {
* exclusion patterns in the resource if a container * exclusion patterns in the resource if a container
* @return * @return
*/ */
public static IMacroEntry newMacroEntry(IPath resourcePath, IPath basePath, String macroName, String macroValue, IPath[] exclusionPatterns) { public static IMacroEntry newMacroEntry(IPath resourcePath, String macroName, String macroValue, IPath[] exclusionPatterns, boolean isExported) {
return new MacroEntry(resourcePath, basePath, macroName, macroValue, exclusionPatterns); return new MacroEntry(resourcePath, null, macroName, macroValue, exclusionPatterns, isExported);
} }
/**
* Creates and returns an entry kind <code>CDT_MACRO</code>
*
* @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 * Answers the project specific value for a given container. In case this
* container path could not be resolved, then will answer <code>null</code>. * container path could not be resolved, then will answer <code>null</code>.

View file

@ -28,6 +28,13 @@ public interface IIncludeEntry extends IPathEntry {
*/ */
IPath getBasePath(); IPath getBasePath();
/**
* Return the reference path
*
* @return
*/
IPath getBaseReference();
/** /**
* Whether or not it a system include path * Whether or not it a system include path
* @return boolean * @return boolean

View file

@ -63,4 +63,11 @@ public interface ILibraryEntry extends IPathEntry {
*/ */
IPath getBasePath(); IPath getBasePath();
/**
* Return the base reference.
*
* @return
*/
IPath getBaseReference();
} }

View file

@ -41,4 +41,10 @@ public interface IMacroEntry extends IPathEntry {
*/ */
IPath getBasePath(); IPath getBasePath();
/**
* return the base reference
* IMacroEntry
*/
IPath getBaseReference();
} }

View file

@ -84,6 +84,10 @@ public interface IPathEntry {
*/ */
boolean isExported(); boolean isExported();
/**
*
* @return IPath
*/
IPath getPath(); IPath getPath();
} }

View file

@ -13,23 +13,32 @@
package org.eclipse.cdt.internal.core.model; package org.eclipse.cdt.internal.core.model;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
public abstract class APathEntry extends PathEntry { public abstract class APathEntry extends PathEntry {
public static IPath[] NO_EXCLUSION_PATTERNS = {}; public static IPath[] NO_EXCLUSION_PATTERNS = {};
public final static IPath EMPTY_PATH = new Path("");
IPath[] exclusionPatterns; IPath[] exclusionPatterns;
IPath basePath; IPath basePath;
IPath baseRef;
private final static char[][] UNINIT_PATTERNS = new char[][] { "Non-initialized yet".toCharArray() }; //$NON-NLS-1$ private final static char[][] UNINIT_PATTERNS = new char[][] { "Non-initialized yet".toCharArray() }; //$NON-NLS-1$
char[][]fullCharExclusionPatterns = UNINIT_PATTERNS; 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); super(kind, path, isExported);
this.basePath = basePath; this.basePath = (basePath == null) ? EMPTY_PATH : basePath;
if (exclusionPatterns == null) { this.baseRef = (baseRef == null) ? EMPTY_PATH : baseRef;
this.exclusionPatterns = NO_EXCLUSION_PATTERNS; this.exclusionPatterns = (exclusionPatterns == null) ? NO_EXCLUSION_PATTERNS : exclusionPatterns;
} else {
this.exclusionPatterns = exclusionPatterns;
}
} }
/** /**
@ -48,6 +57,14 @@ public abstract class APathEntry extends PathEntry {
return basePath; return basePath;
} }
/**
*
* @return
*/
public IPath getBaseReference() {
return baseRef;
}
/** /**
* Returns a char based representation of the exclusions patterns full path. * Returns a char based representation of the exclusions patterns full path.
*/ */

View file

@ -19,9 +19,9 @@ public class IncludeEntry extends APathEntry implements IIncludeEntry {
IPath includePath; IPath includePath;
boolean isSystemInclude; 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) { 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.includePath = includePath;
this.isSystemInclude = isSystemInclude; this.isSystemInclude = isSystemInclude;
} }

View file

@ -22,9 +22,19 @@ public class LibraryEntry extends APathEntry implements ILibraryEntry {
IPath sourceAttachmentRootPath; IPath sourceAttachmentRootPath;
IPath sourceAttachmentPrefixMapping; 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) { 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.sourceAttachmentPath = sourceAttachmentPath;
this.sourceAttachmentRootPath = sourceAttachmentRootPath; this.sourceAttachmentRootPath = sourceAttachmentRootPath;
this.sourceAttachmentPrefixMapping = sourceAttachmentPrefixMapping; this.sourceAttachmentPrefixMapping = sourceAttachmentPrefixMapping;

View file

@ -20,8 +20,8 @@ public class MacroEntry extends APathEntry implements IMacroEntry {
String macroName; String macroName;
String macroValue; String macroValue;
public MacroEntry (IPath path, IPath basePath, String macroName, String macroValue, IPath[] exclusionPatterns) { public MacroEntry (IPath path, IPath baseRef, String macroName, String macroValue, IPath[] exclusionPatterns, boolean isExported) {
super(IMacroEntry.CDT_MACRO, path, basePath, exclusionPatterns, path == null); super(IMacroEntry.CDT_MACRO, null, baseRef, path, exclusionPatterns, isExported);
this.macroName = macroName; this.macroName = macroName;
this.macroValue = macroValue; this.macroValue = macroValue;
} }

View file

@ -20,12 +20,11 @@ public class OutputEntry extends APathEntry implements IOutputEntry {
/** /**
* @param kind * @param kind
* @param path * @param path
* @param isRecursive
* @param exclusionPatterns * @param exclusionPatterns
* @param isExported * @param isExported
*/ */
public OutputEntry(IPath path, IPath[] exclusionPatterns, boolean 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) { public boolean equals(Object obj) {

View file

@ -65,7 +65,8 @@ public class PathEntryManager implements ICDescriptorListener {
static String PATH_ENTRY_ID = "org.eclipse.cdt.core.pathentry"; //$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_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_EXPORTED = "exported"; //$NON-NLS-1$
static String ATTRIBUTE_SOURCEPATH = "sourcepath"; //$NON-NLS-1$ static String ATTRIBUTE_SOURCEPATH = "sourcepath"; //$NON-NLS-1$
static String ATTRIBUTE_ROOTPATH = "roopath"; //$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); isExported = element.getAttribute(ATTRIBUTE_EXPORTED).equals(VALUE_TRUE);
} }
// ensure path is absolute // get path and ensure it is absolute
//boolean hasPath = element.hasAttribute(ATTRIBUTE_PATH); //String pathAttr = element.getAttribute(ATTRIBUTE_PATH);
String pathAttr = element.getAttribute(ATTRIBUTE_PATH); IPath path = new Path(element.getAttribute(ATTRIBUTE_PATH));
IPath path = new Path(pathAttr);
if (!path.isAbsolute()) { if (!path.isAbsolute()) {
path = projectPath.append(path); path = projectPath.append(path);
} }
// check fo the base path // check fo the base path
IPath basePath = new Path(""); //$NON-NLS-1$ IPath basePath = new Path(element.getAttribute(ATTRIBUTE_BASE_PATH));
if (element.hasAttribute(ATTRIBUTE_BASE_PATH)) {
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) // source attachment info (optional)
IPath sourceAttachmentPath = element.hasAttribute(ATTRIBUTE_SOURCEPATH) ? new Path( IPath sourceAttachmentPath = element.hasAttribute(ATTRIBUTE_SOURCEPATH) ? new Path(
@ -706,7 +706,10 @@ public class PathEntryManager implements ICDescriptorListener {
case IPathEntry.CDT_PROJECT : case IPathEntry.CDT_PROJECT :
return CoreModel.newProjectEntry(path, isExported); return CoreModel.newProjectEntry(path, isExported);
case IPathEntry.CDT_LIBRARY : case IPathEntry.CDT_LIBRARY :
return CoreModel.newLibraryEntry(path, basePath, sourceAttachmentPath, sourceAttachmentRootPath, if (!baseRef.isEmpty()) {
return CoreModel.newLibraryRefEntry(baseRef, path);
}
return CoreModel.newLibraryEntry(basePath, path, sourceAttachmentPath, sourceAttachmentRootPath,
sourceAttachmentPrefixMapping, isExported); sourceAttachmentPrefixMapping, isExported);
case IPathEntry.CDT_SOURCE : case IPathEntry.CDT_SOURCE :
{ {
@ -727,21 +730,25 @@ public class PathEntryManager implements ICDescriptorListener {
case IPathEntry.CDT_INCLUDE : case IPathEntry.CDT_INCLUDE :
{ {
// include path info // include path info
IPath includePath = element.hasAttribute(ATTRIBUTE_INCLUDE) IPath includePath = new Path(element.getAttribute(ATTRIBUTE_INCLUDE));
? new Path(element.getAttribute(ATTRIBUTE_INCLUDE))
: null;
// isSysteminclude // isSysteminclude
boolean isSystemInclude = false; boolean isSystemInclude = false;
if (element.hasAttribute(ATTRIBUTE_SYSTEM)) { if (element.hasAttribute(ATTRIBUTE_SYSTEM)) {
isSystemInclude = element.getAttribute(ATTRIBUTE_SYSTEM).equals(VALUE_TRUE); 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 : case IPathEntry.CDT_MACRO :
{ {
String macroName = element.getAttribute(ATTRIBUTE_NAME); String macroName = element.getAttribute(ATTRIBUTE_NAME);
String macroValue = element.getAttribute(ATTRIBUTE_VALUE); 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 : case IPathEntry.CDT_CONTAINER :
{ {
@ -785,17 +792,18 @@ public class PathEntryManager implements ICDescriptorListener {
} }
} }
// Save the path
element.setAttribute(ATTRIBUTE_PATH, xmlPath.toString());
// Specifics to the entries // Specifics to the entries
if (kind == IPathEntry.CDT_SOURCE) { switch(kind) {
element.setAttribute(ATTRIBUTE_PATH, xmlPath.toString()); case IPathEntry.CDT_SOURCE:
} else if (kind == IPathEntry.CDT_OUTPUT) { case IPathEntry.CDT_OUTPUT:
element.setAttribute(ATTRIBUTE_PATH, xmlPath.toString()); case IPathEntry.CDT_PROJECT:
} else if (kind == IPathEntry.CDT_LIBRARY) { case IPathEntry.CDT_CONTAINER:
break;
case IPathEntry.CDT_LIBRARY: {
ILibraryEntry lib = (ILibraryEntry) entries[i]; 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(); IPath sourcePath = lib.getSourceAttachmentPath();
if (sourcePath != null) { if (sourcePath != null) {
// translate to project relative from absolute // translate to project relative from absolute
@ -813,38 +821,38 @@ public class PathEntryManager implements ICDescriptorListener {
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 == IPathEntry.CDT_PROJECT) { break;
element.setAttribute(ATTRIBUTE_PATH, xmlPath.toString()); }
} else if (kind == IPathEntry.CDT_INCLUDE) { case IPathEntry.CDT_INCLUDE: {
IIncludeEntry include = (IIncludeEntry) entries[i]; 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(); IPath includePath = include.getIncludePath();
element.setAttribute(ATTRIBUTE_INCLUDE, includePath.toString()); element.setAttribute(ATTRIBUTE_INCLUDE, includePath.toString());
if (include.isSystemInclude()) { if (include.isSystemInclude()) {
element.setAttribute(ATTRIBUTE_SYSTEM, VALUE_TRUE); element.setAttribute(ATTRIBUTE_SYSTEM, VALUE_TRUE);
} }
} else if (kind == IPathEntry.CDT_MACRO) { break;
}
case IPathEntry.CDT_MACRO: {
IMacroEntry macro = (IMacroEntry) entries[i]; 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_NAME, macro.getMacroName());
element.setAttribute(ATTRIBUTE_VALUE, macro.getMacroValue()); element.setAttribute(ATTRIBUTE_VALUE, macro.getMacroValue());
} else if (kind == IPathEntry.CDT_CONTAINER) { break;
element.setAttribute(ATTRIBUTE_PATH, xmlPath.toString()); }
}
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 // Save the exclusions attributes
if (entries[i] instanceof APathEntry) {
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);

View file

@ -17,8 +17,13 @@ import org.eclipse.core.runtime.IPath;
public class SourceEntry extends APathEntry implements ISourceEntry { 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) { public boolean equals (Object obj) {

View file

@ -34,8 +34,8 @@ public class CPListElement {
public static final String SYSTEM_INCLUDE = "systeminclude"; //$NON-NLS-1$ 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_NAME = "macroname"; //$NON-NLS-1$
public static final String MACRO_VALUE = "macrovalue"; //$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_REF = "base-ref"; //$NON-NLS-1$
public static final String BASE = "base"; //$NON-NLS-1$ public static final String BASE = "base-path"; //$NON-NLS-1$
private ICProject fProject; private ICProject fProject;
@ -123,25 +123,21 @@ public class CPListElement {
return CoreModel.newSourceEntry(fPath, exclusionPattern); return CoreModel.newSourceEntry(fPath, exclusionPattern);
case IPathEntry.CDT_LIBRARY: case IPathEntry.CDT_LIBRARY:
IPath attach = (IPath) getAttribute(SOURCEATTACHMENT); 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: case IPathEntry.CDT_PROJECT:
return CoreModel.newProjectEntry(fPath, isExported()); return CoreModel.newProjectEntry(fPath, isExported());
case IPathEntry.CDT_CONTAINER: case IPathEntry.CDT_CONTAINER:
return CoreModel.newContainerEntry(fPath, isExported()); return CoreModel.newContainerEntry(fPath, isExported());
case IPathEntry.CDT_INCLUDE: case IPathEntry.CDT_INCLUDE:
if (base != null) { 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); ((Boolean) getAttribute(SYSTEM_INCLUDE)).booleanValue(), exclusionPattern);
} else { } else {
} }
case IPathEntry.CDT_MACRO: case IPathEntry.CDT_MACRO:
if (base != null) { return CoreModel.newMacroEntry(fPath, (String) getAttribute(MACRO_NAME),
return CoreModel.newMacroEntry(fPath, base, (String) getAttribute(MACRO_NAME),
(String) getAttribute(MACRO_VALUE), exclusionPattern); (String) getAttribute(MACRO_VALUE), exclusionPattern);
} else {
}
default: default:
return null; return null;
} }