SourceLocation

@UiToolingDataApi
data class SourceLocation


Source location of the call that produced the call group.

Summary

Public constructors

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

Public properties

Int

The length of the source code.

Int

A 0 offset line number of the source location.

Int

Offset into the file.

Int

A hash code of the package name of the file.

String?

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
SourceLocation(
    lineNumber: Int,
    offset: Int,
    length: Int,
    sourceFile: String?,
    packageHash: Int
)

Public properties

length

Added in 1.0.0
val lengthInt

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
val lineNumberInt

A 0 offset line number of the source location.

offset

Added in 1.0.0
val offsetInt

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
val packageHashInt

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 sourceFile. 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
val sourceFileString?

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, packageHash is included to help disambiguate files with duplicate names.