/** Retrieves the current {@link IProject} instance based on the currently opened editor. */
 public static IProject getCurrentProjectForOpenEditor() {
   IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   if (activeWorkbenchWindow != null && activeWorkbenchWindow.getActivePage() != null) {
     IEditorPart p = activeWorkbenchWindow.getActivePage().getActiveEditor();
     if (p == null) {
       IWorkbenchPart activePart = activeWorkbenchWindow.getActivePage().getActivePart();
       if (activePart instanceof PropertySheet) {
         ShowInContext showInContext = ((PropertySheet) activePart).getShowInContext();
         if (showInContext instanceof PropertyShowInContext) {
           IWorkbenchPart part = ((PropertyShowInContext) showInContext).getPart();
           if (part instanceof IEditorPart) {
             p = (IEditorPart) part;
           } else {
             JasperReportsPlugin.getDefault()
                 .logWarning("Unable to retrieve the current project for the open editor.");
             return null;
           }
         }
       }
     }
     IEditorInput editorInput = p.getEditorInput();
     IFile file = getFile(editorInput);
     if (file != null) {
       return file.getProject();
     }
   }
   return null;
 }
  /**
   * Retrieves the list of functions contributed in the specified class reference.
   *
   * <p>The method seeks for annotated methods with the annotation {@link JRExprFunction} in order
   * to build the basic set of functions, and then scan for similar ones to decide which parameters
   * are mandatory and which optional.
   *
   * @param clazz the class reference that is supposed to contain expression functions
   * @return a list of JR expression functions
   */
  public List<JRExprFunctionBean> getFunctionsList(Class<?> clazz) {
    Map<String, List<Method>> methodsCache = buildAnnotatedMethodsCache(clazz);

    List<JRExprFunctionBean> functionsList = new ArrayList<JRExprFunctionBean>();
    for (String functionName : methodsCache.keySet()) {
      try {
        JRExprFunctionBean jrFunction = createJRFunction(methodsCache.get(functionName), clazz);
        functionsList.add(jrFunction);
      } catch (Exception ex) {
        JasperReportsPlugin.getDefault()
            .logError(
                NLS.bind(
                    "Unable to create the function ''{0}'' from class ''{1}''. See full stacktrace.",
                    functionName, clazz.getCanonicalName()),
                ex);
      }
    }

    return functionsList;
  }