コード例 #1
0
  protected void getEnumSwitchCompletions(View view, List<CompletionCandidate> candidates) {
    String prefix = CompletionUtil.getCompletionPrefix(view);
    prefix = prefix == null ? "" : prefix;

    if (!prefix.equals("switch")) {
      return;
    }

    // Global enums
    String q = "kind:enum AND " + TagIndex._PATH_FLD + ":*.hx ";
    Vector<Tag> tags = CtagsInterfacePlugin.runScopedQuery(view, q);

    List<CompletionCandidate> localCandidates = new ArrayList<CompletionCandidate>();

    for (Tag t : tags) {
      if (t.getName().length() > 1) {
        localCandidates.add(new EnumSwitchCompletionCandidate(t));
      }
    }

    Collections.sort(localCandidates);
    candidates.addAll(localCandidates);
  }
コード例 #2
0
  /** Get local members and Haxe classes. */
  protected void getCtagsCompletions(View view, List<CompletionCandidate> candidates) {
    // Ctags cannot current complete dot completion, save that for the compiler.
    if (CompletionUtil.isDotCompletion(view)) {
      return;
    }

    List<CompletionCandidate> localCandidates = new ArrayList<CompletionCandidate>();
    String prefix = CompletionUtil.getCompletionPrefix(view);
    prefix = prefix == null ? "" : prefix;

    // If the prefix is all lower case, ignore case
    boolean islowercase = prefix.toLowerCase().equals(prefix);
    // Local members
    String q =
        (islowercase ? TagIndex._NAME_LOWERCASE_FLD : TagIndex._NAME_FLD)
            + ":"
            + prefix
            + "*"
            + " AND "
            + TagIndex._PATH_FLD
            + ":"
            + view.getBuffer().getPath()
            + " AND (kind:function OR kind:variable)";

    Vector<Tag> tags = CtagsInterfacePlugin.runScopedQuery(view, q);

    for (Tag t : tags) {
      if (t.getName().length() > 1) {
        localCandidates.add(new CtagsCompletionCandidate(t));
      }
    }

    TextArea ta = view.getTextArea();
    // If we're not dot-completing, look for classes
    if (prefix.length() > 0
        && !ta.getText(ta.getCaretPosition() - 1 - prefix.length(), 1).equals(".")) {
      q =
          (islowercase ? TagIndex._NAME_LOWERCASE_FLD : TagIndex._NAME_FLD)
              + ":"
              + prefix
              + "* AND (kind:class OR kind:enum)"
              + " AND "
              + TagIndex._PATH_FLD
              + ":*.hx";
      tags = CtagsInterfacePlugin.runScopedQuery(view, q);
      Set<String> classes = new HashSet<String>();
      for (Tag t : tags) {
        if (!classes.contains(t.getName()) && !prefix.equals(t.getName())) {
          localCandidates.add(new CtagsCompletionCandidate(t));
          classes.add(t.getName());
        }
      }
    }

    Collections.sort(localCandidates);
    candidates.addAll(localCandidates);
  }