-
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
13 changed files
with
276 additions
and
5 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
5 changes: 5 additions & 0 deletions
5
src/IC-242/kotlin/io/kotest/plugin/intellij/contentFactory.kt
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,5 @@ | ||
package io.kotest.plugin.intellij | ||
|
||
import com.intellij.ui.content.ContentFactory | ||
|
||
fun getContentFactory(): ContentFactory = ContentFactory.getInstance() |
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,33 @@ | ||
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>? { | ||
return FilenameIndex | ||
.getVirtualFilesByName(name, scope) | ||
.firstOrNull { it.isTestFile(project) } | ||
?.toPsiFile(project) | ||
?.elementAtLine(lineNumber) | ||
?.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.kotest.plugin.intellij | ||
|
||
import com.intellij.psi.PsiElement | ||
import org.jetbrains.kotlin.idea.codeinsight.utils.findExistingEditor | ||
|
||
fun PsiElement.existingEditor() = this.findExistingEditor() |
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,7 @@ | ||
package io.kotest.plugin.intellij | ||
|
||
import org.jetbrains.kotlin.idea.base.psi.kotlinFqName | ||
import org.jetbrains.kotlin.name.FqName | ||
import org.jetbrains.kotlin.psi.KtClassOrObject | ||
|
||
fun KtClassOrObject.fqname(): FqName? = this.kotlinFqName |
5 changes: 5 additions & 0 deletions
5
src/IC-242/kotlin/io/kotest/plugin/intellij/inspectionsuper.kt
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,5 @@ | ||
package io.kotest.plugin.intellij | ||
|
||
import org.jetbrains.kotlin.idea.codeinsight.api.classic.inspections.AbstractKotlinInspection | ||
|
||
abstract class AbstractInspection : AbstractKotlinInspection() |
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,18 @@ | ||
package io.kotest.plugin.intellij | ||
|
||
import com.intellij.codeInsight.daemon.LineMarkerInfo | ||
import com.intellij.openapi.editor.markup.GutterIconRenderer | ||
import com.intellij.openapi.editor.markup.MarkupEditorFilter | ||
import com.intellij.openapi.editor.markup.MarkupEditorFilterFactory | ||
import com.intellij.psi.PsiElement | ||
import com.intellij.util.Functions | ||
import javax.swing.Icon | ||
|
||
/** | ||
* A Line marker that does not appear in diffs | ||
*/ | ||
class MainEditorLineMarkerInfo(element: PsiElement, text: String, icon: Icon) : LineMarkerInfo<PsiElement>( | ||
element, element.textRange, icon, Functions.constant(text), null, GutterIconRenderer.Alignment.LEFT, { text } | ||
) { | ||
override fun getEditorFilter(): MarkupEditorFilter = MarkupEditorFilterFactory.createIsNotDiffFilter() | ||
} |
68 changes: 68 additions & 0 deletions
68
src/IC-242/kotlin/io/kotest/plugin/intellij/structure/KotestStructureViewExtension.kt
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,68 @@ | ||
package io.kotest.plugin.intellij.structure | ||
|
||
import com.intellij.icons.AllIcons | ||
import com.intellij.ide.structureView.StructureViewExtension | ||
import com.intellij.ide.structureView.StructureViewTreeElement | ||
import com.intellij.ide.util.treeView.smartTree.TreeElement | ||
import com.intellij.navigation.ItemPresentation | ||
import com.intellij.openapi.editor.Editor | ||
import com.intellij.psi.NavigatablePsiElement | ||
import com.intellij.psi.PsiElement | ||
import io.kotest.plugin.intellij.TestElement | ||
import io.kotest.plugin.intellij.psi.specStyle | ||
import org.jetbrains.kotlin.psi.KtClassOrObject | ||
import javax.swing.Icon | ||
|
||
class KotestStructureViewExtension : StructureViewExtension { | ||
|
||
override fun getType(): Class<out PsiElement> { | ||
return KtClassOrObject::class.java | ||
} | ||
|
||
override fun getChildren(parent: PsiElement): Array<StructureViewTreeElement> { | ||
val ktClassOrObject = parent as? KtClassOrObject ?: return emptyArray() | ||
val spec = ktClassOrObject.specStyle() ?: return emptyArray() | ||
val tests = spec.tests(parent, false) | ||
return tests.map { KotestTestStructureViewTreeElement(it) }.toTypedArray() | ||
} | ||
|
||
class KotestTestStructureViewTreeElement(private val test: TestElement) : StructureViewTreeElement { | ||
override fun getPresentation(): ItemPresentation { | ||
return object : ItemPresentation { | ||
override fun getIcon(unused: Boolean): Icon { | ||
return AllIcons.Nodes.Test | ||
} | ||
|
||
override fun getPresentableText(): String { | ||
return test.test.name.displayName() | ||
} | ||
} | ||
} | ||
|
||
override fun getChildren(): Array<TreeElement> { | ||
return test.nestedTests.map { KotestTestStructureViewTreeElement(it) }.toTypedArray() | ||
} | ||
|
||
override fun navigate(requestFocus: Boolean) { | ||
if (test.psi is NavigatablePsiElement) { | ||
test.psi.navigate(true) | ||
} | ||
} | ||
|
||
override fun canNavigate(): Boolean { | ||
return true | ||
} | ||
|
||
override fun canNavigateToSource(): Boolean { | ||
return true | ||
} | ||
|
||
override fun getValue(): Any { | ||
return test | ||
} | ||
} | ||
|
||
override fun getCurrentEditorElement(editor: Editor?, parent: PsiElement?): Any? { | ||
return null | ||
} | ||
} |
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,113 @@ | ||
<idea-plugin> | ||
|
||
<id>kotest-plugin-intellij</id> | ||
<name>Kotest</name> | ||
|
||
<vendor email="sam@sksamuel.com" url="http://github.com/kotest">Kotest</vendor> | ||
|
||
<description><![CDATA[ | ||
Official IntelliJ-based IDEA plugin for <a href="https://github.com/kotest/kotest">Kotest</a>.<br/><br/> | ||
This plugin requires the use of Kotest 4.2.0 or newer. | ||
]]></description> | ||
|
||
<!-- correct values will be set by the build plugin --> | ||
<version>1.0.0</version> | ||
<idea-version since-build="211.6085.26"/> | ||
|
||
<depends>org.jetbrains.kotlin</depends> | ||
<depends>com.intellij.modules.java</depends> | ||
<depends>org.jetbrains.plugins.gradle</depends> | ||
<depends optional="true" config-file="intellilang-kotlin-support.xml">org.intellij.intelliLang</depends> | ||
|
||
<actions> | ||
<action id="io.kotest.actions.NextTestAction" | ||
class="io.kotest.plugin.intellij.actions.NextTestAction" text="Next Test" | ||
description="Navigate to the next test in this spec class"> | ||
<add-to-group group-id="CodeMenu" anchor="last"/> | ||
<keyboard-shortcut keymap="$default" first-keystroke="alt n"/> | ||
</action> | ||
|
||
<action id="io.kotest.actions.PreviousTestAction" | ||
class="io.kotest.plugin.intellij.actions.PreviousTestAction" text="Previous Test" | ||
description="Navigate to the previous test in this spec class"> | ||
<add-to-group group-id="CodeMenu" anchor="last"/> | ||
<keyboard-shortcut keymap="$default" first-keystroke="alt P"/> | ||
</action> | ||
</actions> | ||
|
||
<extensions defaultExtensionNs="com.intellij"> | ||
<configurationType implementation="io.kotest.plugin.intellij.KotestConfigurationType"/> | ||
|
||
<annotator language="kotlin" | ||
implementationClass="io.kotest.plugin.intellij.annotators.DuplicatedTestNameAnnotator"/> | ||
|
||
<annotator language="kotlin" | ||
implementationClass="io.kotest.plugin.intellij.annotators.FocusInNestedTestAnnotator"/> | ||
|
||
<!-- <localInspection groupPath="Kotlin" language="JVM" shortName="ShouldBeInstanceOfInspection"--> | ||
<!-- bundle="KotestGadgetsBundle"--> | ||
<!-- key="kotest.should.be.instance.of"--> | ||
<!-- groupBundle="KotestGadgetsBundle" groupKey="group.names.kotest"--> | ||
<!-- enabledByDefault="true" level="WARNING"--> | ||
<!-- implementationClass="io.kotest.plugin.intellij.inspections.ShouldBeInstanceOfInspection"/>--> | ||
|
||
<toolWindow id="Kotest" anchor="left" icon="/icon13_greyscale.png" | ||
factoryClass="io.kotest.plugin.intellij.toolwindow.TestExplorerToolWindowFactory"/> | ||
|
||
<lang.structureViewExtension implementation="io.kotest.plugin.intellij.structure.KotestStructureViewExtension"/> | ||
|
||
<codeInsight.lineMarkerProvider language="kotlin" implementationClass="io.kotest.plugin.intellij.linemarker.InterpolatedTestLineMarker"/> | ||
<codeInsight.lineMarkerProvider language="kotlin" implementationClass="io.kotest.plugin.intellij.linemarker.DisabledTestLineMarker"/> | ||
<runLineMarkerContributor language="kotlin" implementationClass="io.kotest.plugin.intellij.run.TestRunLineMarkerContributor"/> | ||
<runLineMarkerContributor language="kotlin" implementationClass="io.kotest.plugin.intellij.run.SpecRunLineMarkerContributor"/> | ||
|
||
<runConfigurationProducer implementation="io.kotest.plugin.intellij.run.SpecRunConfigurationProducer"/> | ||
<runConfigurationProducer implementation="io.kotest.plugin.intellij.run.TestPathRunConfigurationProducer"/> | ||
<runConfigurationProducer implementation="io.kotest.plugin.intellij.run.PackageRunConfigurationProducer"/> | ||
<runConfigurationProducer implementation="io.kotest.plugin.intellij.run.GradleSpecRunConfigurationProducer"/> | ||
|
||
<implicitUsageProvider implementation="io.kotest.plugin.intellij.implicits.SpecImplicitUsageProvider"/> | ||
<implicitUsageProvider implementation="io.kotest.plugin.intellij.implicits.ProjectConfigImplicitUsageProvider"/> | ||
<implicitUsageProvider implementation="io.kotest.plugin.intellij.implicits.AutoScanUsageProvider"/> | ||
|
||
<testFinder implementation="io.kotest.plugin.intellij.KotestTestFinder"/> | ||
<testFramework id="Kotest" implementation="io.kotest.plugin.intellij.KotestTestFramework"/> | ||
<testGenerator language="kotlin" implementationClass="io.kotest.plugin.intellij.KotestTestGenerator"/> | ||
|
||
<codeInsight.externalLibraryResolver implementation="io.kotest.plugin.intellij.KotestExternalLibraryResolver"/> | ||
<stacktrace.fold substring="at io.kotest."/> | ||
<programRunner implementation="io.kotest.plugin.intellij.run.KotestDebuggerRunner"/> | ||
<library.dependencyScopeSuggester implementation="io.kotest.plugin.intellij.KotestDependencyScopeSuggester"/> | ||
|
||
<intentionAction> | ||
<className>io.kotest.plugin.intellij.intentions.SoftAssertIntention</className> | ||
<category>Kotlin/Test</category> | ||
<descriptionDirectoryName>SoftAssertIntention</descriptionDirectoryName> | ||
</intentionAction> | ||
|
||
<intentionAction> | ||
<className>io.kotest.plugin.intellij.intentions.BangIntention</className> | ||
<category>Kotlin/Test</category> | ||
<descriptionDirectoryName>BangIntention</descriptionDirectoryName> | ||
</intentionAction> | ||
|
||
<intentionAction> | ||
<className>io.kotest.plugin.intellij.intentions.ShouldThrowIntention</className> | ||
<category>Kotlin/Test</category> | ||
<descriptionDirectoryName>ShouldThrowIntention</descriptionDirectoryName> | ||
</intentionAction> | ||
|
||
<intentionAction> | ||
<className>io.kotest.plugin.intellij.intentions.ShouldThrowAnyIntention</className> | ||
<category>Kotlin/Test</category> | ||
<descriptionDirectoryName>ShouldThrowAnyIntention</descriptionDirectoryName> | ||
</intentionAction> | ||
|
||
<intentionAction> | ||
<className>io.kotest.plugin.intellij.intentions.ShouldThrowExactlyIntention</className> | ||
<category>Kotlin/Test</category> | ||
<descriptionDirectoryName>ShouldThrowExactlyIntention</descriptionDirectoryName> | ||
</intentionAction> | ||
</extensions> | ||
|
||
</idea-plugin> |