package com.chrisfolger.needsmoredojo.testutil;

import com.intellij.lang.ASTNode;
import com.intellij.lang.javascript.psi.JSFunction;
import com.intellij.lang.javascript.psi.JSFunctionExpression;
import com.intellij.lang.javascript.psi.JSParameter;
import com.intellij.lang.javascript.psi.impl.JSFunctionExpressionImpl;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.tree.TokenSet;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import static org.mockito.Mockito.mock;

public class MockJSFunctionExpression extends JSFunctionExpressionImpl
{
    private JSFunction function;
    private JSParameter[] parameters;

    public MockJSFunctionExpression(String[] parameters)
    {
        super(mock(ASTNode.class));

        function = new MockJSFunction(parameters);
    }

    @Override
    public JSFunction getFunction()
    {
        return function;
    }
}

@@ -941,94 +941,399 @@
 s);%0A
-    %7D%0A%0A    @Override%0A    public JSFunction getFunction()%0A    %7B%0A        return function
+%0A        this.parameters = new JSParameter%5Bparameters.length%5D;%0A        for(int i=0;i%3Cparameters.length;i++)%0A        %7B%0A            this.parameters%5Bi%5D = new MockJSParameter(parameters%5Bi%5D);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public JSFunction getFunction()%0A    %7B%0A        return function;%0A    %7D%0A%0A    @NotNull%0A    @Override%0A    public JSParameter%5B%5D getParameters()%0A    %7B%0A        return parameters
 ;%0A  

update mock