-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
87 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.kotest.plugin.intellij | ||
|
||
import com.intellij.execution.PsiLocation | ||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.vfs.VirtualFile | ||
import com.intellij.psi.PsiElement | ||
import com.intellij.psi.search.FilenameIndex | ||
import com.intellij.psi.search.GlobalSearchScope | ||
import io.kotest.plugin.intellij.psi.elementAtLine | ||
import io.kotest.plugin.intellij.psi.isTestFile | ||
import io.kotest.plugin.intellij.psi.toPsiLocation | ||
import io.kotest.plugin.intellij.toolwindow.TagsFilename | ||
import org.jetbrains.kotlin.idea.core.util.toPsiFile | ||
|
||
fun findFiles(project: Project): List<VirtualFile> { | ||
return FilenameIndex | ||
.getVirtualFilesByName(TagsFilename, false, GlobalSearchScope.allScope(project)) | ||
.toList() | ||
} | ||
|
||
fun getLocationForFile( | ||
project: Project, | ||
scope: GlobalSearchScope, | ||
name: String, | ||
lineNumber: Int | ||
): PsiLocation<PsiElement>? { | ||
val testFile = FilenameIndex.getVirtualFilesByName(name, scope).firstOrNull { it.isTestFile(project) } ?: return null | ||
// element at line is 1 indexed, so we need to add one | ||
return testFile.toPsiFile(project)?.elementAtLine(lineNumber + 1)?.toPsiLocation() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters