@Override public void visitFunctionExpression(FunctionExpressionTree tree) { enterScope(tree); super.visitFunctionExpression(tree); leaveScope(); }
@Override public void visitFunctionExpression(FunctionExpressionTree tree) { startScopeBlock(); super.visitFunctionExpression(tree); finishScopeBlock(); }
@Override public void visitFunctionExpression(FunctionExpressionTree tree) { checkNumberOfParameters(tree.parameters()); super.visitFunctionExpression(tree); }
@Override public void visitFunctionExpression(FunctionExpressionTree tree) { if (tree.name() != null){ getContext().addIssue(this, tree, "Make this function anonymous by removing its name: 'function() {...}'."); } super.visitFunctionExpression(tree); }
/** * Detail about <a href="http://people.mozilla.org/~jorendorff/es6-draft.html#sec-function-definitions-runtime-semantics-evaluation">Function Expression scope</a> * <blockquote> * The BindingIdentifier in a FunctionExpression can be referenced from inside the FunctionExpression's FunctionBody * to allow the function to call itself recursively. However, unlike in a FunctionDeclaration, the BindingIdentifier * in a FunctionExpression cannot be referenced from and does not affect the scope enclosing the FunctionExpression. * </blockquote> **/ @Override public void visitFunctionExpression(FunctionExpressionTree tree) { newScope(tree); IdentifierTree name = tree.name(); if (name != null) { // Not available in enclosing scope symbolModel.declareSymbol(name.name(), Symbol.Kind.FUNCTION, currentScope).addUsage(Usage.create(name, Usage.Kind.DECLARATION)); } declareParameters(((ParameterListTreeImpl) tree.parameters()).parameterIdentifiers()); addFunctionBuiltInSymbols(); super.visitFunctionExpression(tree); leaveScope(); }