# SourceLocation

Artifact: [androidx.compose.ui:ui-tooling-data](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/tooling/data/SlotTree.jvmAndAndroid.kt+class:androidx.compose.ui.tooling.data.SourceLocation) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)


```
@UiToolingDataApi
data class SourceLocation
```

<br />

*** ** * ** ***

Source location of the call that produced the call group.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/SourceLocation#SourceLocation(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.String,kotlin.Int)( lineNumber: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, offset: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, sourceFile: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?, packageHash: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/SourceLocation#length()` The length of the source code. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/SourceLocation#lineNumber()` A 0 offset line number of the source location. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/SourceLocation#offset()` Offset into the file. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/SourceLocation#packageHash()` A hash code of the package name of the file. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html?` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/SourceLocation#sourceFile()` The file name (without path information) of the source file that contains the call that produced the group. |

## Public constructors

### SourceLocation

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
SourceLocation(
    lineNumber: Int,
    offset: Int,
    length: Int,
    sourceFile: String?,
    packageHash: Int
)
```

## Public properties

### length

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val length: Int
```

The length of the source code. The length is calculated as the number of UTF-16 code units that that make up the call expression.

### lineNumber

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val lineNumber: Int
```

A 0 offset line number of the source location.

### offset

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val offset: Int
```

Offset into the file. The offset is calculated as the number of UTF-16 code units from the beginning of the file to the first UTF-16 code unit of the call that produced the group.

### packageHash

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val packageHash: Int
```

A hash code of the package name of the file. This hash is calculated by,

`packageName.fold(0) { hash, current -> hash * 31 + current.toInt() }?.absoluteValue`

where the package name is the dotted name of the package. This can be used to disambiguate which file is referenced by `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/SourceLocation#(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.String,kotlin.Int)`. This number is -1 if there was no package hash information generated such as when the file does not contain a package declaration.

### sourceFile

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val sourceFile: String?
```

The file name (without path information) of the source file that contains the call that produced the group. A source file names are not guaranteed to be unique, `https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/data/SourceLocation#(kotlin.Int,kotlin.Int,kotlin.Int,kotlin.String,kotlin.Int)` is included to help disambiguate files with duplicate names.