[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [cdt-dev] Creating a CDT_INCLUDE IPathEntry for a filesystem path
|
Thanks! Works great.
On a side note, is:
toArray(new IPathEntry[checkedPaths.size()])
a better, more efficient way to get an array from a vector beside:
toArray(new IPathEntry[0])
?
I usually use the zero-sized array argument so I never make a mistake on
the size (example below I used the {} notation). But, if your example is
faster under-the-hood, I think I'll try it going forward.
Thanks,
Chad
cdt-dev-admin@xxxxxxxxxxx wrote on 01/26/2005 10:18:20 PM:
> >
> > All,
> >
> > Any clues on how to programmatically create a CDT_INCLUDE type
IPathEntry
> > for a standard make project that references a filesystem location?
> >
> > Currently, I have code that works with paths within the project:
> >
> > for (int i = 0; i < includePaths.length; i++) {
> > currentElement = new CPElement(cProj, IPathEntry.CDT_INCLUDE,
> > proj.getFullPath(), proj.getFolder(includePaths[i]));
> > currentElement.setAttribute(CPElement.INCLUDE,
> > proj.getFolder(includePaths[i]).getLocation());
> > checkedPaths.add(currentElement.getPathEntry());
> > }
> > cProj.setRawPathEntries((IPathEntry[]) checkedPaths.toArray(new
> > IPathEntry[] {}), new SubProgressMonitor(monitor, 7));
> >
> > But, what if includePaths[i] == C:\Local_Includes? How do I add this
as a
> > valid IPathEntry? I tried creating a simple PathEntry() object, but
got a
> > ClassCastException down the road. I then looked at the constructor
> > parameters for IncludeEntry:
> >
> > IPath resourcePath,
> > IPath basePath,
> > IPath baseRef,
> > IPath includePath,
> > boolean isSystemInclude,
> > IPath[] exclusionPatterns,
> > boolean isExported
> >
> > ...but, I don't know what these parameters expect from a filesystem
path.
> >
>
> Use the CoreModel class factory.
>
> IProject project = ...
> ..
> IPath myIncludePath = new Path("C:\Local_Includes");
> IIncludeEntry include = CoreModel.newIncludeEntry(project.
> getFullPath(), null, myIncludePath));
> checkedPaths.add(include);
> ...
> cProject.setRawPathEntries((IPathEntry[])checkedPaths.toArray(new
> IPathEntry[checkedPaths.size()]), null);
>
> The JavaDoc:
> /**
> * Creates and returns a new entry of kind <code>CDT_INCLUDE</code>
> *
> * @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 basePath, IPath includePath) {
> return newIncludeEntry(resourcePath, basePath, includePath, false);
> }
>
>
> I definitively agree with what you are saying implicitely... we need
> some ISV docs 8-)
> And we should be put in the plan items for CDT-3.0 ....
>
>
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/cdt-dev