Package org.eclipse.cdt.core.model

# Interface ISourceReference

All Known Subinterfaces:
  `IAsmLabel`, `IBinaryFunction`, `IBinaryVariable`, `IConcept`, `IDeclaration`, `IEnumeration`, `IEnumerator`, `IField`, `IFunction`, `IFunctionDeclaration`, `IFunctionTemplate`, `IFunctionTemplateDeclaration`, `IInclude`, `IMacro`, `IMember`, `IMethod`, `IMethodDeclaration`, `IMethodTemplate`, `IMethodTemplateDeclaration`, `INamespace`, `IPragma`, `IStructure`, `IStructureDeclaration`, `IStructureTemplate`, `IStructureTemplateDeclaration`, `ITranslationUnit`, `ITypeDef`, `IUsing`, `IVariable`, `IVariableDeclaration`, `IWorkingCopy`

public interface ISourceReference
Common protocol for C elements that have associated source code.

Note: For `IBinary`, `IArchive` and other members derived from a binary type, the implementation returns source iff the element has attached source code and debugging information.

Restriction:
  This interface is not intended to be implemented by clients.
Restriction:
  This interface is not intended to be extended by clients.

## Method Summary

Modifier and Type
Method
Description
`int`
`getIndex()`
Allows to differentiate otherwise equal elements of the same file.
`String`
`getSource()`
Returns the source code associated with this element.
`ISourceRange`
`getSourceRange()`
Returns the source range associated with this element.
`ITranslationUnit`
`getTranslationUnit()`
Returns the translation unit in which this member is declared, or `null` if this member is not declared in a translation unit (for example, a binary type).
`boolean`
`isActive()`
Returns whether this element is in active code.

## Method Details

### getSource

String getSource() throws CModelException
Returns the source code associated with this element.

For binary files, this returns the source of the entire translation unit associated with the binary file (if there is one).

Returns:
  the source code, or `null` if this element has no associated source code
Throws:
  `CModelException` - if this element does not exist or if an exception occurs while accessing its corresponding resource

### getSourceRange

ISourceRange getSourceRange() throws CModelException
Returns the source range associated with this element.

For binary files, this returns the range of the entire translation unit associated with the binary file (if there is one).

Returns:
  the source range, or `null` if if this element has no associated source code
Throws:
  `CModelException` - if this element does not exist or if an exception occurs while accessing its corresponding resource

### getTranslationUnit

ITranslationUnit getTranslationUnit()
Returns the translation unit in which this member is declared, or `null` if this member is not declared in a translation unit (for example, a binary type).

### isActive

boolean isActive()
Returns whether this element is in active code. Code is inactive when it is hidden by conditional compilation.

Since:
  5.1

### getIndex

int getIndex()
Allows to differentiate otherwise equal elements of the same file.

Since:
  5.1