Package org.eclipse.cdt.core.index

# Class IndexLocationFactory

java.lang.Object
org.eclipse.cdt.core.index.IndexLocationFactory

public class IndexLocationFactory extends Object
Factory for obtaining instances of IIndexFileLocation for workspace and external files, and some utility methods for going in the opposite direction.

Since:
  4.0
Restriction:
  This class is not intended to be subclassed by clients.
Restriction:
  This class is not intended to be instantiated by clients.

## Constructor Summary

Constructors
Constructor
Description
`IndexLocationFactory()`

## Method Summary

Modifier and Type
Method
Description
`static org.eclipse.core.runtime.IPath`
`getAbsolutePath(IIndexFileLocation location)`
Returns the absolute file path of a location, or `null` if the location is not a file-system path.
`static IIndexFileLocation`
`getExternalIFL(String absolutePath)`
Returns an IIndexFileLocation for the specified absolute path, with no associated full path.
`static IIndexFileLocation`
`getExternalIFL(org.eclipse.core.runtime.IPath absolutePath)`
Returns an IIndexFileLocation for the specified absolute path, with no associated full path.
`static IIndexFileLocation`
`getIFL(ITranslationUnit tu)`
Returns a workspace IIndexFileLocation if the translation unit has an associated resource an external IIndexFileLocation if the translation unit does not have an associated resource null, in any other case
`static IIndexFileLocation`
`getIFLExpensive(String absolutePath)`
Equivalent to the overloaded form with the ICProject parameter set to null
`static IIndexFileLocation`
`getIFLExpensive(ICProject cproject, String absolutePath)`
Returns an IIndexFileLocation by searching the workspace for resources that are mapped onto the specified absolute path.
`static org.eclipse.core.runtime.IPath`
`getPath(IIndexFileLocation location)`
Returns the full path if this IIndexFileLocation is within the workspace root the absolute path if this IIndexFileLocation is URI based and corresponds to a location on the local file system otherwise, null
`static IIndexFileLocation`
`getWorkspaceIFL(org.eclipse.core.resources.IFile file)`
Returns an IIndexFileLocation for the specified workspace file, or `null` if it does not have a location.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### IndexLocationFactory

public IndexLocationFactory()

## Method Details

### getPath

public static org.eclipse.core.runtime.IPath getPath(IIndexFileLocation location)
Returns

- the full path if this IIndexFileLocation is within the workspace root
- the absolute path if this IIndexFileLocation is URI based and corresponds to a location on the local file system
- otherwise, null

Parameters:
  `location` -
Returns:
  the workspace root relative path, a local file system absolute path or null

### getAbsolutePath

public static org.eclipse.core.runtime.IPath getAbsolutePath(IIndexFileLocation location)
Returns the absolute file path of a location, or `null` if the location is not a file-system path.

### getIFLExpensive

public static IIndexFileLocation getIFLExpensive(String absolutePath)
Equivalent to the overloaded form with the ICProject parameter set to null

See Also:
  - `getIFLExpensive(ICProject, String)`

### getIFLExpensive

public static IIndexFileLocation getIFLExpensive(ICProject cproject, String absolutePath)
Returns an IIndexFileLocation by searching the workspace for resources that are mapped onto the specified absolute path.

If such a resource exists, an IIndexFileLocation that contains both the resource location URI, and the resources full path is created.

Otherwise, an IIndexFileLocation which contains the absolute path in URI form is returned.

N.B. As this searches the workspace, following links and potentially reading from alternate file systems, this method may be expensive.

Parameters:
  `cproject` - the ICProject to prefer when resolving external includes to workspace resources (may be null)
  `absolutePath` -
Returns:
  an IIndexFileLocation for the specified resource, containing a workspace relative path if possible.

### getExternalIFL

public static IIndexFileLocation getExternalIFL(String absolutePath)
Returns an IIndexFileLocation for the specified absolute path, with no associated full path.

Parameters:
  `absolutePath` -
Returns:
  an IIndexFileLocation for the specified absolute path, with no associated full path.

### getExternalIFL

public static IIndexFileLocation getExternalIFL(org.eclipse.core.runtime.IPath absolutePath)
Returns an IIndexFileLocation for the specified absolute path, with no associated full path.

Parameters:
  `absolutePath` -
Returns:
  an IIndexFileLocation for the specified absolute path, with no associated full path.

### getWorkspaceIFL

public static IIndexFileLocation getWorkspaceIFL(org.eclipse.core.resources.IFile file)
Returns an IIndexFileLocation for the specified workspace file, or `null` if it does not have a location.

Parameters:
  `file` -
Returns:
  an IIndexFileLocation for the specified workspace file

### getIFL

public static IIndexFileLocation getIFL(ITranslationUnit tu)
Returns

- a workspace IIndexFileLocation if the translation unit has an associated resource
- an external IIndexFileLocation if the translation unit does not have an associated resource
- null, in any other case

Parameters:
  `tu` -
Returns:
  a suitable IIndexFileLocation for the specified ITranslationUnit