org.eclipse.cdt.core.model

## Interface ISourceReference

All Known Subinterfaces:
  IAsmLabel, IBinaryFunction, IBinaryVariable, IDeclaration, IEnumeration, IEnumerator, IField, IFunction, IFunctionDeclaration, IFunctionTemplate, IFunctionTemplateDeclaration, IInclude, IMacro, IMember, IMethod, IMethodDeclaration, IMethodTemplate, IMethodTemplateDeclaration, INamespace, 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.

### Method Summary

All Methods Instance Methods Abstract Methods
`int` `getIndex()` Allows to differentiate otherwise equal elements of the same file.
`java.lang.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 Detail

#### getSource

    java.lang.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