org.eclipse.wst.jsdt.core

## Interface ISourceReference

All Known Subinterfaces:
  IClassFile, IExportContainer, IExportDeclaration, IField, IFunction, IImportContainer, IImportDeclaration, IInitializer, IJavaScriptUnit, ILocalVariable, IMember, IType, ITypeRoot

    public interface ISourceReference

Common protocol for JavaScript elements that have associated source code. This set consists of `IClassFile`, `IJavaScriptUnit`, `IPackageDeclaration`, `IImportDeclaration`, `IImportContainer`, `IType`, `IField`, `IFunction`, and `IInitializer`.

Source reference elements may be working copies if they were created from a compilation unit that is a working copy.

This interface is not intended to be implemented by clients.

See Also:
  `Provisional API: This class/interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is being made available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.`

### Method Summary

All Methods Instance Methods Abstract Methods
`boolean` `exists()` Returns whether this element exists in the model.
`java.lang.String` `getSource()` Returns the source code associated with this element.
`ISourceRange` `getSourceRange()` Returns the source range associated with this element.

### Method Detail

#### exists

    boolean exists()

Returns whether this element exists in the model.

Returns:
  `true` if this element exists in the JavaScript model

#### getSource

    java.lang.String getSource()
                        throws JavaScriptModelException

Returns the source code associated with this element. This extracts the substring from the source buffer containing this source element. This corresponds to the source range that would be returned by `getSourceRange`.

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

#### getSourceRange

    ISourceRange getSourceRange()
                         throws JavaScriptModelException

Returns the source range associated with this element.

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