Skip to content

Commit

Permalink
Add file path for KSFile. Fix fileName documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
neetopia committed Sep 28, 2020
1 parent f5b6219 commit 4f4c624
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion api/src/main/kotlin/com/google/devtools/ksp/symbol/KSFile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ interface KSFile : KSDeclarationContainer, KSAnnotated {
val packageName: KSName

/**
* Absolute path of this source file.
* File name of this source file.
*/
val fileName: String

/**
* Absolute path of this source file.
*/
val filePath: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class KSFileJavaImpl private constructor(val psi: PsiJavaFile) : KSFile {
psi.name
}

override val filePath: String by lazy {
psi.virtualFile.path
}

override val packageName: KSName = KSNameImpl.getCached(if (psi.packageName == "") "<root>" else psi.packageName)

override fun <D, R> accept(visitor: KSVisitor<D, R>, data: D): R {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class KSFileImpl private constructor(val file: KtFile) : KSFile {
file.name
}

override val filePath: String by lazy {
file.virtualFilePath
}

override fun <D, R> accept(visitor: KSVisitor<D, R>, data: D): R {
return visitor.visitFile(this, data)
}
Expand Down

0 comments on commit 4f4c624

Please sign in to comment.