Skip to content

Commit

Permalink
fix(line-marker): Fix to use identifier
Browse files Browse the repository at this point in the history
Per docs, line markers should always be to identifiers, not higher types
  • Loading branch information
olivernybroe committed Jul 27, 2020
1 parent 7ade45a commit 31bdc3c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@ package com.pestphp.pest

import com.intellij.execution.lineMarker.RunLineMarkerContributor
import com.intellij.psi.PsiElement
import com.jetbrains.php.lang.lexer.PhpTokenTypes
import com.jetbrains.php.lang.psi.PhpPsiUtil
import com.jetbrains.php.lang.psi.elements.impl.FunctionReferenceImpl

class PestTestRunLineMarkerProvider : RunLineMarkerContributor() {
override fun getInfo(leaf: PsiElement): Info? {
if (leaf !is FunctionReferenceImpl || !leaf.isPestTestReference()) {
if (!PhpPsiUtil.isOfType(leaf, PhpTokenTypes.IDENTIFIER)) {
return null
}

if (leaf.parent !is FunctionReferenceImpl || !leaf.parent.isPestTestReference()) {
return null
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ class PestTestRunLineMarkerProviderTest : PestLightCodeFixture() {
fun testMethodCallNamedItAndVariableTestIsNotPestTest() {
val file = myFixture.configureByFile("MethodCallNamedItAndVariableTest.php")

val testElement = file.firstChild.lastChild.firstChild
val testElement = file.firstChild.lastChild.firstChild.firstChild

assertNull(PestTestRunLineMarkerProvider().getInfo(testElement))
}

fun testFunctionCallNamedItWithDescriptionAndClosure() {
val file = myFixture.configureByFile("PestItFunctionCallWithDescriptionAndClosure.php")

val testElement = file.firstChild.lastChild.firstChild
val testElement = file.firstChild.lastChild.firstChild.firstChild

assertNotNull(PestTestRunLineMarkerProvider().getInfo(testElement))
}
Expand Down

0 comments on commit 31bdc3c

Please sign in to comment.