Java Code Examples for com.intellij.lang.javascript.psi.JSCallExpression#getArguments()

The following examples show how to use com.intellij.lang.javascript.psi.JSCallExpression#getArguments() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavascriptTestContextProvider.java    From intellij with Apache License 2.0 5 votes vote down vote up
private static boolean isImportingTestSuite(PsiElement element) {
  JSCallExpression call = PsiTreeUtil.getChildOfType(element, JSCallExpression.class);
  if (call == null || !Objects.equals(call.getMethodExpression().getText(), "goog.require")) {
    return false;
  }
  JSExpression[] arguments = call.getArguments();
  if (arguments.length != 1) {
    return false;
  }
  if (!(arguments[0] instanceof JSLiteralExpression)) {
    return false;
  }
  JSLiteralExpression literal = (JSLiteralExpression) arguments[0];
  return Objects.equals(literal.getStringValue(), "goog.testing.testSuite");
}
 
Example 2
Source File: BlazeJavaScriptTestRunLineMarkerContributorTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
private Subject assertThatJasmineElement(LeafPsiElement element) {
  Info info = markerContributor.getInfo(element);
  assertThat(info).isNotNull();
  return new Subject() {
    @Override
    public Subject isTestSuite() {
      assertThat(element.getText()).isEqualTo("describe");
      return this;
    }

    @Override
    public Subject isTestCase() {
      assertThat(element.getText()).isEqualTo("it");
      return this;
    }

    @Override
    public Subject hasName(String name) {
      PsiElement grandParent = element.getParent().getParent();
      assertThat(grandParent).isInstanceOf(JSCallExpression.class);
      JSCallExpression call = (JSCallExpression) grandParent;
      assertThat(call.getArguments()[0]).isInstanceOf(JSLiteralExpression.class);
      JSLiteralExpression literal = (JSLiteralExpression) call.getArguments()[0];
      assertThat(literal.getStringValue()).isEqualTo(name);
      return this;
    }

    @Override
    public Subject hasIcon(Icon icon) {
      assertThat(info.icon).isEqualTo(icon);
      return this;
    }
  };
}