public void importClassesFromParameters(JSArgumentList signalParams, JSClass jsClass) {
   JSExpression[] arguments = signalParams.getArguments();
   for (JSExpression argument : arguments) {
     PsiElement resolve = ((JSReferenceExpression) argument).resolve();
     String qualifiedName = ((JSClass) resolve).getQualifiedName();
     ImportUtils.importAndShortenReference(qualifiedName, jsClass, true, true);
   }
 }
 private String replaceParamsWithArgs(
     Project project, JSArgumentList argumentList, PsiElement signal) {
   String signalText = signal.getLastChild().getText();
   String signalHandlerName =
       "on"
           + signalText.substring(0, 1).toUpperCase()
           + signalText.substring(1, signalText.length());
   PsiElement signalHandler =
       JSChangeUtil.createJSTreeFromText(project, "(" + signalHandlerName + ")").getPsi();
   argumentList.replace(signalHandler);
   return signalHandlerName;
 }
  private PsiElement generateHandlerFromParams(
      Project project, JSFile file, String signalHandlerName, JSArgumentList signalParams) {
    JSClass jsClass = JSPsiImplUtils.findClass(file);

    importClassesFromParameters(signalParams, jsClass);

    String result = SignalsUtils.buildParametersFromClassParameters(signalParams.getText());

    ASTNode jsTreeFromText =
        JSChangeUtil.createJSTreeFromText(
            project,
            "protected function " + signalHandlerName + result + ":void{" + "" + "\n}\n",
            JavaScriptSupportLoader.ECMA_SCRIPT_L4);

    final PsiElement functionElement = jsTreeFromText.getPsi();

    return jsClass.add(functionElement);
  }