use of org.jetbrains.plugins.scala.lang.psi.api.expr.ScInfixExpr in project intellij by bazelbuild.
the class BlazeScalaSpecs2TestExprConfigurationProducer method testLocation.
@Nullable
private static TestLocation testLocation(ConfigurationContext context) {
// Handled by SM runner.
if (!SmRunnerUtils.getSelectedSmRunnerTreeElements(context).isEmpty()) {
return null;
}
ScInfixExpr testCase = Specs2Utils.getContainingTestExprOrScope(context.getPsiLocation());
if (testCase == null) {
return null;
}
ScTypeDefinition testClass = PsiTreeUtil.getParentOfType(testCase, ScTypeDefinition.class);
if (testClass == null) {
return null;
}
TestSize testSize = TestSizeAnnotationMap.getTestSize(testClass);
TargetInfo target = RunUtil.targetForTestClass(testClass, testSize);
if (target == null) {
return null;
}
return new TestLocation(target, testClass, testCase);
}
use of org.jetbrains.plugins.scala.lang.psi.api.expr.ScInfixExpr 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;
}
use of org.jetbrains.plugins.scala.lang.psi.api.expr.ScInfixExpr in project intellij by bazelbuild.
the class BlazeScalaTestLocator method findTestCase.
@SuppressWarnings("rawtypes")
private List<Location> findTestCase(Project project, String path) {
String[] parts = path.split(SmRunnerUtils.TEST_NAME_PARTS_SPLITTER, 2);
if (parts.length < 2) {
return ImmutableList.of();
}
String className = parts[0];
String testName = parts[1];
PsiClass testClass = ClassUtil.findPsiClass(PsiManager.getInstance(project), className);
for (ScInfixExpr testCase : PsiTreeUtil.findChildrenOfType(testClass, ScInfixExpr.class)) {
if (TestNodeProvider.isSpecs2TestExpr(testCase) && Objects.equal(Specs2Utils.getSpecs2ScopedTestName(testCase), testName)) {
return ImmutableList.of(new PsiLocation<>(testCase));
}
}
return ImmutableList.of();
}
use of org.jetbrains.plugins.scala.lang.psi.api.expr.ScInfixExpr in project intellij by bazelbuild.
the class Specs2Utils method getSpecs2ScopedTestName.
@Nullable
public static String getSpecs2ScopedTestName(ScInfixExpr testCase) {
String testName = getSpecs2TestName(testCase);
if (testName == null) {
return null;
}
ScInfixExpr testScope = getContainingTestScope(testCase);
if (testScope == null) {
return testName;
}
String scopeName = getSpecs2ScopeName(testScope);
if (scopeName == null) {
return testName;
}
return scopeName + SmRunnerUtils.TEST_NAME_PARTS_SPLITTER + testName;
}
Aggregations