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 void addLanguageKeyword(CompletionResultSet resultSet, String text) {
   // TODO:: order most common used first
   String keywords =
       "|abs|accept|alarm|atan2|AUTOLOAD|BEGIN|bind|binmode|bless|break|caller|chdir|CHECK|chmod|chomp|chop|chown|chr|chroot|close|closedir|connect|cos|crypt|dbmclose|dbmopen|defined|delete|DESTROY|die|dump|each|END|endgrent|endhostent|endnetent|endprotoent|endpwent|endservent|eof|eval|exec|exists|exit|fcntl|fileno|flock|fork|format|formline|getc|getgrent|getgrgid|getgrnam|gethostbyaddr|gethostbyname|gethostent|getlogin|getnetbyaddr|getnetbyname|getnetent|getpeername|getpgrp|getppid|getpriority|getprotobyname|getprotobynumber|getprotoent|getpwent|getpwnam|getpwuid|getservbyname|getservbyport|getservent|getsockname|getsockopt|glob|gmtime|goto|grep|hex|index|INIT|int|ioctl|join|keys|kill|last|lc|each|lcfirst|setnetent|length|link|listen|local|localtime|log|lstat|map|mkdir|msgctl|msgget|msgrcv|msgsnd|next|not|oct|open|opendir|ord|our|pack|pipe|pop|pos|print|printf|prototype|push|quotemeta|rand|read|readdir|readline|readlink|readpipe|recv|redo|ref|rename|require|reset|return|reverse|rewinddir|rindex|rmdir|say|scalar|seek|seekdir|select|semctl|semget|semop|send|setgrent|sethostent|each|lcfirst|setnetent|setpgrp|setpriority|setprotoent|setpwent|setservent|setsockopt|shift|shmctl|shmget|shmread|shmwrite|shutdown|sin|sleep|socket|socketpair|sort|splice|split|sprintf|sqrt|srand|stat|state|study|substr|symlink|syscall|sysopen|sysread|sysseek|system|syswrite|tell|telldir|tie|tied|time|times|truncate|ucfirst|umask|undef|UNITCHECK|unlink|unpack|unshift|untie|use|utime|values|vec|wait|waitpid|wantarray|warn|write|each|lcfirst|setnetent|cmp|continue|CORE|else|elsif|exp|for|foreach|lock|package|unless|until|while|ARGV|ARGVOUT|STDERR|STDIN|STDOUT";
   Matcher matcher = Utils.applyRegex("\\|(" + text + "[^\\|]+)", keywords);
   while (matcher.find()) {
     resultSet.addElement(LookupElementBuilder.create(matcher.group(1)));
   }
 }
 private static void addCachedVariables(CompletionResultSet resultSet, String str) {
   if (str != null && !variablesCache.containsKey(str)) {
     if (Utils.verbose) {
       Utils.print("cache variable: " + str);
     }
     variablesCache.put(str, getVariableLookupElementBuilder(str));
   }
   if (resultSet != null) {
     resultSet.addElement(variablesCache.get(str));
   }
 }
 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));
   }
 }
 public static void initialize() {
   float start = 0;
   if (Utils.verbose) {
     start = System.currentTimeMillis();
   }
   cacheAllPackages();
   cacheAllSubsAndVarsOfOpenedFiles();
   if (Utils.verbose) {
     float end = System.currentTimeMillis();
     Utils.print("performance[intcch]: " + ((end - start) / 1000) + "sec");
   }
 }
 private static void addCachedSubNoArgs(CompletionResultSet resultSet, Sub sub) {
   if (!subsCacheNoArgs.containsKey(sub)) {
     if (Utils.verbose) {
       Utils.print(
           "cache sub(no args): "
               + sub.getName()
               + " , containingPackage:"
               + sub.getPackageObj().getQualifiedName());
     }
     subsCacheNoArgs.put(sub, getSubLookupElementBuilder(sub, false));
   }
   if (resultSet != null) {
     resultSet.addElement(subsCacheNoArgs.get(sub));
   }
 }
 @Override
 public void selectionChanged(FileEditorManagerEvent event) {
   if (Utils.verbose) {
     Utils.print("file changed to:" + event.getNewFile());
   }
 }