private void checkForAMDPattern(CallExpressionTree tree) {
   if (tree.callee().is(Kind.IDENTIFIER_REFERENCE)
       && "define".equals(((IdentifierTree) tree.callee()).name())) {
     for (Tree parameter : tree.arguments().parameters()) {
       if (parameter.is(Kind.FUNCTION_EXPRESSION)) {
         amdPattern = true;
       }
     }
   }
 }
  private void checkAngularModuleMethodCall(CallExpressionTree tree) {
    if (tree.callee().is(Kind.DOT_MEMBER_EXPRESSION)) {
      DotMemberExpressionTree callee = (DotMemberExpressionTree) tree.callee();

      if (callee.object().types().contains(Type.Kind.ANGULAR_MODULE)) {
        SeparatedList<Tree> parameters = tree.arguments().parameters();

        if (!parameters.isEmpty()) {
          Tree lastArgument = parameters.get(parameters.size() - 1);

          checkArrayLiteral(lastArgument);
          checkSimpleArgument(lastArgument);
        }
      }
    }
  }
  @Override
  public void visitNode(Tree tree) {
    if (tree.is(Kind.CALL_EXPRESSION)) {
      CallExpressionTree callExpressionTree = (CallExpressionTree) tree;
      checkForImmediatelyInvokedFunction(callExpressionTree.callee());
      checkForAMDPattern(callExpressionTree);
      checkAngularModuleMethodCall(callExpressionTree);
      return;
    }

    if (tree.is(Kind.NEW_EXPRESSION)) {
      if (((NewExpressionTree) tree).arguments() != null) {
        checkForImmediatelyInvokedFunction(((NewExpressionTree) tree).expression());
      }
      return;
    }

    if (!immediatelyInvokedFunctionExpression && !amdPattern && !angularExclusions.contains(tree)) {
      checkFunction((FunctionTree) tree);
    }

    clearCheckState();
  }