Example #1
0
  public static List<Function> getFunctionByName(
      String funName, @Nullable Collection<RPackage> importedPackages) {

    RPackageService packageService = RPackageService.getInstance();

    if (packageService == null) return Collections.emptyList();

    // if the user didn't import anything do a global search todo: does this make sense???
    if (importedPackages == null) {
      importedPackages = packageService.getPackages();
    } else {
      importedPackages = addImportDependencies(importedPackages);
    }

    List<Function> funs = new ArrayList<Function>();
    for (RPackage importedPackage : importedPackages) {
      if (importedPackage.hasFunction(funName)) funs.add(importedPackage.getFunction(funName));
    }

    return funs;
  }