Search in sources :

Example 1 with ScFunctionDefinition

use of org.jetbrains.plugins.scala.lang.psi.api.statements.ScFunctionDefinition in project intellij by bazelbuild.

the class BlazeScalaTestRunLineMarkerContributor method getInfo.

@Nullable
@Override
public Info getInfo(PsiElement element) {
    if (isIdentifier(element)) {
        PsiElement testElement = element.getParent();
        if (testElement instanceof ScClass) {
            return getInfo((ScClass) testElement, null, super.getInfo(element));
        }
        ScClass testClass = PsiTreeUtil.getParentOfType(testElement, ScClass.class);
        if (testClass == null) {
            return null;
        }
        if (testElement instanceof ScFunctionDefinition) {
            return getInfo(testClass, testElement, super.getInfo(element));
        }
        if (testElement.getParent() instanceof ScInfixExpr) {
            ScInfixExpr infixExpr = (ScInfixExpr) testElement.getParent();
            if (infixExpr.operation().equals(testElement)) {
                return getInfo(testClass, infixExpr, super.getInfo(element));
            }
        }
    }
    return null;
}
Also used : ScInfixExpr(org.jetbrains.plugins.scala.lang.psi.api.expr.ScInfixExpr) ScFunctionDefinition(org.jetbrains.plugins.scala.lang.psi.api.statements.ScFunctionDefinition) PsiElement(com.intellij.psi.PsiElement) ScClass(org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.ScClass) Nullable(javax.annotation.Nullable)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 Nullable (javax.annotation.Nullable)1 ScInfixExpr (org.jetbrains.plugins.scala.lang.psi.api.expr.ScInfixExpr)1 ScFunctionDefinition (org.jetbrains.plugins.scala.lang.psi.api.statements.ScFunctionDefinition)1 ScClass (org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.ScClass)1