1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 22:25:25 +02:00

Starting implementation of CPathEntry entries

in the core model.
This commit is contained in:
Alain Magloire 2003-10-21 19:44:35 +00:00
parent 8968c45d84
commit 47a0ffc0e9
16 changed files with 1141 additions and 12 deletions

View file

@ -4,10 +4,15 @@ package org.eclipse.cdt.core.model;
* (c) Copyright QNX Software Systems Ltd. 2002.
* All Rights Reserved.
*/
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.internal.core.model.BatchOperation;
import org.eclipse.cdt.internal.core.model.CModelManager;
import org.eclipse.cdt.internal.core.model.ContainerEntry;
import org.eclipse.cdt.internal.core.model.IncludeEntry;
import org.eclipse.cdt.internal.core.model.MacroEntry;
import org.eclipse.cdt.internal.core.model.ProjectEntry;
import org.eclipse.cdt.internal.core.model.SourceEntry;
import org.eclipse.cdt.internal.core.search.indexing.IndexManager;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
@ -24,7 +29,7 @@ public class CoreModel {
private static CoreModel cmodel = null;
private static CModelManager manager = null;
public final static String CORE_MODEL_ID = CCorePlugin.PLUGIN_ID + ".coremodel";
/**
@ -119,7 +124,7 @@ public class CoreModel {
/**
* Return true if name is a valid name for a translation unit.
*/
public boolean isValidTranslationUnitName(String name){
public boolean isValidTranslationUnitName(String name) {
return manager.isValidTranslationUnitName(name);
}
@ -147,17 +152,288 @@ public class CoreModel {
/**
* Return true if project has C nature.
*/
public boolean hasCNature(IProject project){
public boolean hasCNature(IProject project) {
return manager.hasCNature(project);
}
/**
* Return true if project has C++ nature.
*/
public boolean hasCCNature(IProject project){
public boolean hasCCNature(IProject project) {
return manager.hasCCNature(project);
}
/**
* Creates and returns a new non-exported entry of kind <code>CDT_PROJECT</code>
* for the project identified by the given absolute path.
* <p>
* A project entry is used to denote a prerequisite project.
* The ICPathEntry[] entries of the project will be contributed.
* <p>
* The prerequisite project is referred to using an absolute path relative to the workspace root.
* <p>
* The resulting entry is not exported to dependent projects. This method is equivalent to
* <code>newProjectEntry(path,false)</code>.
* <p>
*
* @param path the absolute path of the binary archive
* @return a new project entry
*
* @see CoreModel#newProjectEntry(IPath, boolean)
*/
public static IProjectEntry newProjectEntry(IPath path) {
return newProjectEntry(path, false);
}
/**
* Creates and returns a new entry of kind <code>CDT_PROJECT</code>
* for the project identified by the given absolute path.
* <p>
* A project entry is used to denote a prerequisite project.
* All the ICPathEntries 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>
*
* @param path the absolute path of the prerequisite project
* @param isExported indicates whether this entry is contributed to dependent
* projects in addition to the output location
* @return a new project entry
*/
public static IProjectEntry newProjectEntry(IPath path, boolean isExported) {
return new ProjectEntry(path, isExported);
}
/**
* Creates and returns a new entry of kind <code>CDT_CONTAINER</code>
* 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>
* The resulting entry is not exported to dependent projects. This method is equivalent to
* <code>newContainerEntry(path,false)</code>.
* <p>
* @param containerPath the id of the container
* @return a new container entry
*
*/
public static IContainerEntry newContainerEntry(String id) {
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 used during resolution so as to map this
* container entry to a set of other entries the container is acting for.
* <p>
* The resulting entry is not exported to dependent projects. This method is equivalent to
* <code>newContainerEntry(path,false)</code>.
* <p>
*/
public static IContainerEntry newContainerEntry(String id, boolean 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 given absolute path.
*
* Note that this operation does not attempt to validate or access the
* resources at the given paths.
* <p>
* The resulting entry is not exported to dependent projects. This method is equivalent to
* <code>newLibraryEntry(-,-,-,false)</code>.
* <p>
* @param path the absolute path of the binary archive
* @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
*
*/
public static ILibraryEntry newLibraryEntry(
IPath path,
IPath sourceAttachmentPath,
IPath sourceAttachmentRootPath,
IPath sourceAttachmentPrefixMapping) {
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 given absolute path.
*
* Note that this operation does not attempt to validate or access the
* resources at the given paths.
* <p>
* @param path the absolute path of the binary archive
* @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
*
*/
public static ILibraryEntry newLibraryEntry(
IPath path,
IPath sourceAttachmentPath,
IPath sourceAttachmentRootPath,
IPath sourceAttachmentPrefixMapping,
boolean isExported) {
return newLibraryEntry(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 absolute
* workspace-relative path.
* <p>
* The source folder is referred to using an absolute path relative to the
* workspace root, e.g. <code>/Project/src</code>. A project's source
* 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>
* 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.
* </p>
*
* @param path the absolute workspace-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);
}
/**
* Creates and returns a new entry of kind <code>CDT_SOURCE</code>
* for the project's source folder identified by the given absolute
* 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>
* The source folder is referred to using an absolute path relative to the
* workspace root, e.g. <code>/Project/src</code>. A project's source
* 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>
*
* @param path the absolute workspace-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 newSourceEntry(path, null, exclusionPatterns);
}
/**
* Creates and returns a new entry of kind <code>CDT_SOURCE</code>
* for the project's source folder identified by the given absolute
* 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>
* The source folder is referred to using an absolute path relative to the
* workspace root, e.g. <code>/Project/src</code>. A project's source
* 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>
* @param path the absolute workspace-relative path of a source folder
* @param exclusionPatterns the possibly empty list of exclusion patterns
* represented as relative paths
* @param specificOutputLocation 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
*/
public static ISourceEntry newSourceEntry(IPath path, IPath outputLocation, IPath[] exclusionPatterns) {
return new SourceEntry(path, outputLocation, true, exclusionPatterns);
}
/**
* Creates and returns a new entry of kind <code>CDT_INCLUDE</code>
* @param path the affected worksapce-relative resource path
* @param includePath the absolute path of the include
* @return
*/
public static IIncludeEntry newIncludeEntry(IPath path, IPath includePath) {
return newIncludeEntry(path, includePath, false);
}
/**
* Creates and returns a new entry of kind <code>CDT_INCLUDE</code>
* @param path the affected workspace-relative resource path
* @param includePath the absolute path of the include
* @param isSystemInclude wheter this include path should be consider the system include path
* @return
*/
public static IIncludeEntry newIncludeEntry(IPath path, IPath includePath, boolean isSystemInclude) {
return newIncludeEntry(path, includePath, isSystemInclude, true, IncludeEntry.NO_EXCLUSION_PATTERNS, true);
}
/**
* Creates and returns a new entry of kind <code>CDT_INCLUDE</code>
*
* @param path the affected workspace-relative resource path
* @param includePath the absolute 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
* @param isExported whether this cpath is exported.
* @return
*/
public static IIncludeEntry newIncludeEntry(
IPath path,
IPath includePath,
boolean isSystemInclude,
boolean isRecursive,
IPath[] exclusionPatterns,
boolean isExported) {
return new IncludeEntry(path, includePath, isSystemInclude, isRecursive, exclusionPatterns, isExported);
}
/**
* Creates and returns an entry kind <code>CDT_MACRO</code>
* @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 path, String macroName, String macroValue) {
return newMacroEntry(path, macroName, macroValue, true, MacroEntry.NO_EXCLUSION_PATTERNS, true);
}
/**
* Creates and returns an entry kind <code>CDT_MACRO</code>
* @param path the affected workspace-relative resource path
* @param macroName the name of the macro
* @param macroValue the value of the macro
* @param isRecursive if the resource is a folder the include applied to all recursively
* @param exclusionPatterns exclusion patterns in the resource if a container
* @param isExported whether this cpath is exported.
* @return
*/
public static IMacroEntry newMacroEntry(
IPath path,
String macroName,
String macroValue,
boolean isRecursive,
IPath[] exclusionPatterns,
boolean isExported) {
return new MacroEntry(path, macroName, macroValue, isRecursive, exclusionPatterns, isExported);
}
/**
* TODO: this is a temporary hack until, the CDescriptor manager is
* in place and could fire deltas of Parser change.
@ -206,7 +482,6 @@ public class CoreModel {
private CoreModel() {
}
public static void run(IWorkspaceRunnable action, IProgressMonitor monitor) throws CoreException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
if (workspace.isTreeLocked()) {
@ -216,13 +491,12 @@ public class CoreModel {
workspace.run(new BatchOperation(action), monitor);
}
}
public void startIndexing()
{
manager.getIndexManager().reset();
public void startIndexing() {
manager.getIndexManager().reset();
}
public IndexManager getIndexManager(){
public IndexManager getIndexManager() {
return manager.getIndexManager();
}
}

View file

@ -0,0 +1,96 @@
/**********************************************************************
* 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;
public interface ICPathEntry {
/**
* Entry kind constant describing a path entry identifying a
* library. A library is an archive containing
* consisting of pre-compiled binaries.
*/
int CDT_LIBRARY = 1;
/**
* Entry kind constant describing a path entry identifying a
* required project.
*/
int CDT_PROJECT = 2;
/**
* Entry kind constant describing a path entry identifying a
* folder containing source code to be compiled.
*/
int CDT_SOURCE = 3;
/*
* Entry kind constant describing a path entry defined using
* a path that begins with a variable reference.
*/
int CDT_VARIABLE = 4;
/**
* Entry kind constant describing a path entry identifying a
* include path.
*/
int CDT_INCLUDE = 5;
/**
* Entry kind constant describing a path entry representing
* a container id.
*
*/
int CDT_CONTAINER = 6;
/**
* Entry kind constant describing a path entry representing
* a macro definition.
*
*/
int CDT_MACRO = 7;
/**
* Entry kind constant describing output location
*
*/
int CDT_OUTPUT = 8;
/**
* Returns the kind of this path entry.
*
* @return one of:
* <ul>
* <li><code>CDT_SOURCE</code> - this entry describes a source root in
its project
* <li><code>CDT_LIBRARY</code> - this entry describes a library
* <li><code>CDT_PROJECT</code> - this entry describes another project
* <li><code>CDT_VARIABLE</code> - this entry describes a project or library
* indirectly via a variable in the first segment of the path
* <li><code>CDT_INCLUDE</code> - this entry describes a include path
* <li><code>CDT_MACRO</code> - this entry describes a macro definition
* <li><code>CDT_CONTAINER</code> - this entry describes a container id
* <li><code>CDT_OUTPUT</code> - this entry describes output location
*/
int getEntryKind();
/**
* Returns whether this entry is exported to dependent projects.
* Always returns <code>false</code> for source entries (kind
* <code>CPE_SOURCE</code>), which cannot be exported.
*
* @return <code>true</code> if exported, and <code>false</code> otherwise
*/
boolean isExported();
}

View file

@ -0,0 +1,23 @@
/**********************************************************************
* 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;
public interface IContainerEntry extends ICPathEntry {
/**
* Returns the id identifying this container.
* @return String
*/
String getId();
}

View file

@ -0,0 +1,50 @@
/**********************************************************************
* 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;
public interface IIncludeEntry extends ICPathEntry {
/**
* Returns the affected resource by the include.
* @return IPath
*/
IPath getResourcePath();
/**
* Returns the include path
* @return IPath
*/
IPath getIncludePath();
/**
* Whether or not it a system include path
* @return boolean
*/
boolean isSystemInclude();
/**
* Whether or not the include affects the resource(if it is a folder)
* recursively
* @return boolean
*/
boolean isRecursive();
/**
* If isRecursive() is true, specify an exclude file patterns.
* @return IPath
*/
IPath[] getExclusionPatterns();
}

View file

@ -0,0 +1,66 @@
/**********************************************************************
* 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;
public interface ILibraryEntry extends ICPathEntry {
/**
* Returns the absolute path of the library
* @return String
*/
IPath getLibraryPath();
/**
* Returns the path to the source archive or folder associated with this
* C path entry, or <code>null</code> if this C path entry has no
* source attachment.
* <p>
* Only library and variable C path entries may have source attachments.
* For library C path entries, the result path (if present) locates a source
* archive or folder. This archive or folder can be located in a project of the
* workspace or outside thr workspace. For variable c path entries, the
* result path (if present) has an analogous form and meaning as the
* variable path, namely the first segment is the name of a c path variable.
* </p>
*
* @return the path to the source archive or folder, or <code>null</code> if none
*/
IPath getSourceAttachmentPath();
/**
* Returns the path within the source archive or folder where source
* are located. An empty path indicates that packages are located at
* the root of the source archive or folder. Returns a non-<code>null</code> value
* if and only if <code>getSourceAttachmentPath</code> returns
* a non-<code>null</code> value.
*
* @return the path within the source archive or folder, or <code>null</code> if
* not applicable
*/
IPath getSourceAttachmentRootPath();
/**
* Returns the path to map the source paths with to the source achive or folder
* An empty path indicates that the is a one-to-one mapping of source paths to the
* source achive or folder path. Returns a non-<code>null</code> value
* if and only if <code>getSourceAttachmentPath</code> returns
* a non-<code>null</code> value.
*
* @return the path mapping within the source archive or folder, or <code>null</code> if
* not applicable
*/
IPath getSourceAttachmentPrefixMapping();
}

View file

@ -0,0 +1,51 @@
/**********************************************************************
* 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;
public interface IMacroEntry extends ICPathEntry {
/**
* Returns the absolute path from the worskspace root or
* relative path of the affected resource.
* @return String
*/
IPath getResourcePath();
/**
* Returns the macro name.
* @return String
*/
String getMacroName();
/**
* Returns the macro value.
* @return String
*/
String getMacroValue();
/**
* Whether or not the macro is applied recursively.
* @return boolean
*/
boolean isRecursive();
/**
* Returns an array of inclusion paths affecting the
* resource when looking for files recursively.
* @return IPath
*/
IPath[] getExclusionPatterns();
}

View file

@ -0,0 +1,26 @@
/**********************************************************************
* 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;
public interface IProjectEntry extends ICPathEntry {
/**
* Returns the absolute path relative to the workspace root.
* @return IPath
*/
IPath getProjectPath();
}

View file

@ -0,0 +1,46 @@
/**********************************************************************
* 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;
public interface ISourceEntry extends ICPathEntry {
/**
* Returns the absolute path from the worskspace root or
* relative path of the source folder.
* @return String
*/
IPath getSourcePath();
/**
* Whether or not to look recursively in the folder.
* @return boolean
*/
boolean isRecursive();
/**
* Returns an array of inclusion paths affecting the
* source folder when looking for files recursively.
* @return IPath
*/
IPath[] getExclusionPatterns();
/**
* Binary output location for this source folder.
* @return IPath, <code>null</code> means to use the
* default output location of the project.
*/
IPath getOutputLocation();
}

View file

@ -0,0 +1,45 @@
/**********************************************************************
* Created on 25-Mar-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 org.eclipse.core.runtime.IPath;
public abstract class ACPathEntry extends CPathEntry {
public static IPath[] NO_EXCLUSION_PATTERNS = {};
IPath[] exclusionPatterns;
boolean isRecursive;
public ACPathEntry (int kind, boolean isRecursive, IPath[] exclusionPatterns, boolean isExported) {
super(kind, isExported);
this.exclusionPatterns = exclusionPatterns;
this.isRecursive = isRecursive;
}
/**
* Returns the exclusion patterns
* @return IPath[]
*/
public IPath[] getExclusionPatterns() {
return exclusionPatterns;
}
/**
* Whether or not it is recursive
* @return boolean
*/
public boolean isRecursive() {
return isRecursive;
}
}

View file

@ -0,0 +1,133 @@
/**********************************************************************
* Created on 25-Mar-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 org.eclipse.cdt.core.model.ICPathEntry;
public class CPathEntry implements ICPathEntry {
public int entryKind;
public boolean isExported;
public CPathEntry(int entryKind, boolean isExported) {
this.entryKind = entryKind;
this.isExported = isExported;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.ICPathEntry#getEntryKind()
*/
public int getEntryKind() {
return entryKind;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.ICPathEntry#isExported()
*/
public boolean isExported() {
return isExported;
}
public boolean equals(ICPathEntry otherEntry) {
return entryKind == otherEntry.getEntryKind();
}
public boolean equals(Object object) {
if (object instanceof ICPathEntry) {
return equals((ICPathEntry)object);
}
return super.equals(object);
}
/**
* Returns the kind from its <code>String</code> form.
*/
static int kindFromString(String kindStr) {
if (kindStr.equalsIgnoreCase("prj")) //$NON-NLS-1$
return ICPathEntry.CDT_PROJECT;
if (kindStr.equalsIgnoreCase("var")) //$NON-NLS-1$
return ICPathEntry.CDT_VARIABLE;
if (kindStr.equalsIgnoreCase("src")) //$NON-NLS-1$
return ICPathEntry.CDT_SOURCE;
if (kindStr.equalsIgnoreCase("lib")) //$NON-NLS-1$
return ICPathEntry.CDT_LIBRARY;
if (kindStr.equalsIgnoreCase("inc")) //$NON-NLS-1$
return ICPathEntry.CDT_INCLUDE;
if (kindStr.equalsIgnoreCase("mac")) //$NON-NLS-1$
return ICPathEntry.CDT_MACRO;
if (kindStr.equalsIgnoreCase("con")) //$NON-NLS-1$
return ICPathEntry.CDT_CONTAINER;
return -1;
}
/**
* Returns a <code>String</code> for the kind of a path entry.
*/
static String kindToString(int kind) {
switch (kind) {
case ICPathEntry.CDT_PROJECT :
return "prj";
case ICPathEntry.CDT_SOURCE :
return "src"; //$NON-NLS-1$
case ICPathEntry.CDT_LIBRARY :
return "lib"; //$NON-NLS-1$
case ICPathEntry.CDT_VARIABLE :
return "var"; //$NON-NLS-1$
case ICPathEntry.CDT_INCLUDE :
return "inc"; //$NON-NLS-1$
case ICPathEntry.CDT_MACRO :
return "mac"; //$NON-NLS-1$
case ICPathEntry.CDT_CONTAINER :
return "con"; //$NON-NLS-1$
default :
return "unknown"; //$NON-NLS-1$
}
}
/**
* Returns a printable representation of this classpath entry.
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append('[');
switch (getEntryKind()) {
case ICPathEntry.CDT_LIBRARY :
buffer.append("CDT_LIBRARY"); //$NON-NLS-1$
break;
case ICPathEntry.CDT_PROJECT :
buffer.append("CDT_PROJECT"); //$NON-NLS-1$
break;
case ICPathEntry.CDT_SOURCE :
buffer.append("CDT_SOURCE"); //$NON-NLS-1$
break;
case ICPathEntry.CDT_VARIABLE :
buffer.append("CDT_VARIABLE"); //$NON-NLS-1$
break;
case ICPathEntry.CDT_INCLUDE :
buffer.append("CDT_INCLUDE"); //$NON-NLS-1$
break;
case ICPathEntry.CDT_MACRO :
buffer.append("CDT_MACRO"); //$NON-NLS-1$
break;
case ICPathEntry.CDT_CONTAINER :
buffer.append("CDT_CONTAINER"); //$NON-NLS-1$
break;
}
buffer.append(']');
return buffer.toString();
}
}

View file

@ -0,0 +1,34 @@
/**********************************************************************
* 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 org.eclipse.cdt.core.model.IContainerEntry;
public class ContainerEntry extends CPathEntry implements IContainerEntry {
String id;
public ContainerEntry(String id, boolean isExported) {
super(IContainerEntry.CDT_CONTAINER, isExported);
this.id = id;
}
/**
* Returns the id identifying this container.
* @return String
*/
public String getId() {
return id;
}
}

View file

@ -0,0 +1,56 @@
/**********************************************************************
* Created on 25-Mar-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 org.eclipse.cdt.core.model.IIncludeEntry;
import org.eclipse.core.runtime.IPath;
public class IncludeEntry extends ACPathEntry implements IIncludeEntry {
IPath resourcePath;
IPath includePath;
boolean isSystemInclude;
public IncludeEntry(IPath resourcePath, IPath includePath, boolean isSystemInclude,
boolean isRecursive, IPath[] exclusionPatterns, boolean isExported) {
super(IIncludeEntry.CDT_INCLUDE, isRecursive, exclusionPatterns, isExported);
this.resourcePath = resourcePath;
this.includePath = includePath;
this.isSystemInclude = isSystemInclude;
}
/**
* Returns the affected resource by the include.
* @return IPath
*/
public IPath getResourcePath() {
return resourcePath;
}
/**
* Returns the include path
* @return IPath
*/
public IPath getIncludePath() {
return includePath;
}
/**
* Whether or not it a system include path
* @return boolean
*/
public boolean isSystemInclude() {
return isSystemInclude;
}
}

View file

@ -0,0 +1,89 @@
/**********************************************************************
* 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 org.eclipse.cdt.core.model.ILibraryEntry;
import org.eclipse.core.runtime.IPath;
public class LibraryEntry extends CPathEntry implements ILibraryEntry {
IPath libraryPath;
IPath sourceAttachmentPath;
IPath sourceAttachmentRootPath;
IPath sourceAttachmentPrefixMapping;
public LibraryEntry(IPath libraryPath, IPath sourceAttachmentPath,
IPath sourceAttachmentRootPath, IPath sourceAttachmentPrefixMapping, boolean isExported) {
super(ILibraryEntry.CDT_LIBRARY, isExported);
this.libraryPath = libraryPath;
this.sourceAttachmentPath = sourceAttachmentPath;
this.sourceAttachmentRootPath = sourceAttachmentRootPath;
this.sourceAttachmentPrefixMapping = sourceAttachmentPrefixMapping;
}
/**
* Returns the absolute path of the library
* @return String
*/
public IPath getLibraryPath() {
return libraryPath;
}
/**
* Returns the path to the source archive or folder associated with this
* C path entry, or <code>null</code> if this C path entry has no
* source attachment.
* <p>
* Only library and variable C path entries may have source attachments.
* For library C path entries, the result path (if present) locates a source
* archive or folder. This archive or folder can be located in a project of the
* workspace or outside thr workspace. For variable c path entries, the
* result path (if present) has an analogous form and meaning as the
* variable path, namely the first segment is the name of a c path variable.
* </p>
*
* @return the path to the source archive or folder, or <code>null</code> if none
*/
public IPath getSourceAttachmentPath() {
return sourceAttachmentPath;
}
/**
* Returns the path within the source archive or folder where source
* are located. An empty path indicates that packages are located at
* the root of the source archive or folder. Returns a non-<code>null</code> value
* if and only if <code>getSourceAttachmentPath</code> returns
* a non-<code>null</code> value.
*
* @return the path within the source archive or folder, or <code>null</code> if
* not applicable
*/
public IPath getSourceAttachmentRootPath() {
return sourceAttachmentRootPath;
}
/**
* Returns the path to map the source paths with to the source achive or folder
* An empty path indicates that the is a one-to-one mapping of source paths to the
* source achive or folder path. Returns a non-<code>null</code> value
* if and only if <code>getSourceAttachmentPath</code> returns
* a non-<code>null</code> value.
*
* @return the path mapping within the source archive or folder, or <code>null</code> if
* not applicable
*/
public IPath getSourceAttachmentPrefixMapping() {
return sourceAttachmentPrefixMapping;
}
}

View file

@ -0,0 +1,57 @@
/**********************************************************************
* 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 org.eclipse.cdt.core.model.IMacroEntry;
import org.eclipse.core.runtime.IPath;
public class MacroEntry extends ACPathEntry implements IMacroEntry {
IPath resourcePath;
String macroName;
String macroValue;
public MacroEntry (IPath resourcePath, String macroName, String macroValue,
boolean isRecursive, IPath[] exclusionPatterns, boolean isExported) {
super(IMacroEntry.CDT_MACRO, isRecursive, exclusionPatterns, isExported);
this.resourcePath = resourcePath;
this.macroName = macroName;
this.macroValue = macroValue;
}
/**
* Returns the absolute path from the worskspace root or
* relative path of the affected resource.
* @return String
*/
public IPath getResourcePath() {
return resourcePath;
}
/**
* Returns the macro name.
* @return String
*/
public String getMacroName() {
return macroName;
}
/**
* Returns the macro value.
* @return String
*/
public String getMacroValue() {
return macroName;
}
}

View file

@ -0,0 +1,36 @@
/**********************************************************************
* 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 org.eclipse.cdt.core.model.IProjectEntry;
import org.eclipse.core.runtime.IPath;
public class ProjectEntry extends CPathEntry implements IProjectEntry {
IPath projectPath;
public ProjectEntry(IPath projectPath, boolean isExported) {
super(IProjectEntry.CDT_PROJECT, isExported);
this.projectPath = projectPath;
}
/**
* Returns the absolute path relative to the workspace root.
* @return IPath
*/
public IPath getProjectPath() {
return projectPath;
}
}

View file

@ -0,0 +1,47 @@
/**********************************************************************
* 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 org.eclipse.cdt.core.model.ISourceEntry;
import org.eclipse.core.runtime.IPath;
public class SourceEntry extends ACPathEntry implements ISourceEntry {
IPath sourcePath;
IPath outputLocation;
public SourceEntry(IPath sourcePath, IPath outputLocation, boolean isRecursive, IPath[] exclusionPatterns) {
super(ISourceEntry.CDT_SOURCE, isRecursive, exclusionPatterns, false);
this.sourcePath = sourcePath;
this.outputLocation = outputLocation;
}
/**
* Returns the absolute path from the worskspace root or
* relative path of the source folder.
* @return String
*/
public IPath getSourcePath() {
return sourcePath;
}
/**
* Binary output location for this source folder.
* @return IPath, <code>null</code> means to use the
* default output location of the project.
*/
public IPath getOutputLocation() {
return outputLocation;
}
}