use of com.intellij.lang.javascript.psi.JSArgumentList in project intellij-plugins by JetBrains.
the class JstdGenerateNewTestAction method buildGenerator.
@Nullable
private static Runnable buildGenerator(@NotNull JstdTestFileStructure fileStructure, @NotNull GenerateActionContext context) {
int caretOffset = context.getDocumentCaretOffset();
JstdTestCaseStructure jstdTestCaseStructure = fileStructure.findEnclosingTestCaseByOffset(caretOffset);
if (jstdTestCaseStructure != null) {
JSObjectLiteralExpression testsObjectLiteral = jstdTestCaseStructure.getTestsObjectsLiteral();
if (testsObjectLiteral != null) {
return new TestGeneratorOnObjectLiteral(testsObjectLiteral, context);
} else {
if (jstdTestCaseStructure.getTestCount() == 0) {
JSCallExpression callExpression = jstdTestCaseStructure.getEnclosingCallExpression();
JSArgumentList argumentList = callExpression.getArgumentList();
JSExpression[] arguments = JsPsiUtils.getArguments(argumentList);
if (arguments.length == 1 && arguments[0] != null) {
return new TestGeneratorOnNewlyCreatedObjectLiteral(argumentList, context);
}
}
}
} else {
for (JstdTestCaseStructure testCaseStructure : fileStructure.getTestCaseStructures()) {
JSObjectLiteralExpression testsObjectLiteral = testCaseStructure.getTestsObjectsLiteral();
if (testsObjectLiteral != null && JsPsiUtils.containsOffsetStrictly(testsObjectLiteral.getTextRange(), caretOffset)) {
return new TestGeneratorOnObjectLiteral(testsObjectLiteral, context);
}
}
}
return null;
}
Aggregations