コード例 #1
0
  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));
        }
      }
    }
  }
コード例 #2
0
  // ==================
  // add cached methods
  // ==================
  private void addAllPackages(
      CompletionResultSet resultSet, PerlElement element, boolean limitResults) {
    ArrayList<Package> packageList = ModulesContainer.searchPackageList(element.getText(), false);

    for (int i = 0; i < packageList.size(); i++) {
      addCachedPackage(resultSet, packageList.get(i));
    }
  }
コード例 #3
0
  /**
   * this will try to autocomplete subroutines from package in block like this: use PACKAGE qw( sub1
   * sub2 ... )
   *
   * <p>returns true if contributed some results, false otherwise
   *
   * @return
   */
  public boolean tryAutocompletePackageSubImportBlock(
      PerlElement currentElement,
      @NotNull CompletionParameters parameters,
      @NotNull CompletionResultSet resultSet) {
    if (currentElement.isAny(PerlTypes.WHITESPACE, PerlTypes.BRACES, PerlTypes.PROPERTY)) {
      PerlElement maybeBrace = currentElement;
      if (!maybeBrace.is(
          PerlTypes.BRACES)) { // if we are not already on brace go back permitting only vars and
        // whitespace
        maybeBrace =
            maybeBrace.previousIgnoring(
                PerlTypes.WHITESPACE, PerlTypes.VARIABLE, PerlTypes.PROPERTY);
      }

      if (maybeBrace.is(
          PerlTypes.BRACES)) { // after going back check once more if it is brace already
        PerlElement tmp = maybeBrace.previousIgnoringWhitespace();
        if (tmp.is(PerlTypes.LANG_SYNTAX) && tmp.getText().equals("qw")) {
          PerlElement potentialPackage = tmp.previousIgnoringWhitespace();
          if (potentialPackage.is(PerlTypes.PACKAGE)) {
            tmp = potentialPackage.previousIgnoringWhitespace();
            if (tmp.is(PerlTypes.LANG_FUNCTION) && tmp.getText().equals("use")) {
              addAllSubsInPackage(resultSet, potentialPackage, false, parameters.isAutoPopup());
              return true;
            }
          }
        }
      }
    }
    return false;
  }