private void addAllSubsInPackage(
      CompletionResultSet resultSet,
      PerlElement packageName,
      boolean withArguments,
      boolean limitResults) {
    ArrayList<Package> packageList = ModulesContainer.getPackageList(packageName.getText());

    if (Utils.verbose) {
      Utils.print("Detected Package:" + packageName);
    }
    for (int i = 0; i < packageList.size(); i++) {
      Package packageObj = packageList.get(i);

      ArrayList<Sub> subs = packageObj.getAllSubs();
      int amount =
          (false)
              ? Math.min(AUTO_POPUP_SUBS_ITEMS_LIMIT, subs.size())
              : subs.size(); // get all results only if users press ctrl+space
      for (int j = 0; j < amount; j++) {
        if (withArguments) {
          addCachedSub(resultSet, subs.get(j));
        } else {
          addCachedSubNoArgs(resultSet, subs.get(j));
        }
      }
    }
  }
 private static void addCachedPackage(CompletionResultSet resultSet, Package packageObj) {
   if (packageObj != null && !packagesCache.containsKey(packageObj)) {
     if (Utils.verbose) {
       Utils.print("cache package: " + packageObj.getQualifiedName());
     }
     packagesCache.put(packageObj, getPackageLookupElementBuilder(packageObj));
   }
   if (resultSet != null) {
     resultSet.addElement(packagesCache.get(packageObj));
   }
 }
 // get lookup elements methods
 private static LookupElement getPackageLookupElementBuilder(Package packageObj) {
   String text = packageObj.getQualifiedName();
   return LookupElementBuilder.create(text)
       .withIcon(PerlIcons.PACKAGE)
       .withTypeText("Package", true);
 }