Exemple #1
0
  /**
   * Returns a list with all comment code elements in the AST, except those that exist of fewer
   * lines than <code>minLineCount</code>.
   *
   * @param minLineCount Minimum line count
   * @param doc The IDocument the AST was generated for
   * @return The list with comment elements
   */
  public List getCommentList(int minLineCount, IDocument doc) {
    List resList = getCommentList();
    int endLine = 0, startLine = 0;

    for (int i = 0; i < resList.size(); i++) {
      CodeElement actual = (CodeElement) resList.get(i);
      try {
        startLine = doc.getLineOfOffset(actual.getOffset());
        // multi line comments include one character more than necessary (for folding)
        endLine = doc.getLineOfOffset(actual.getOffset() + actual.getLength() - 1);
      } catch (BadLocationException e) {
        continue;
      }
      if (endLine - startLine + 1 < minLineCount) {
        resList.remove(i);
        i--; // decrease i because we removed one element!
      }
    }
    return resList;
  }
Exemple #2
0
 public static CodeElement getCopy(CodeElement orig) {
   CodeElement res = new CodeElement(orig.getParent(), orig.getCodeType());
   res.setAccessType(orig.getAccessType());
   res.setChildren(orig.children);
   res.setDerived(orig.getDerived());
   res.setElementName(orig.getElementName());
   res.setTypeSignature(orig.getTypeSignature());
   res.setEndPoint(orig.getEndPoint());
   res.setLength(orig.getLength());
   res.setNameOffset(orig.getNameOffset());
   res.setOffset(orig.getOffset());
   res.setSignature(orig.getSignature());
   res.setSource(orig.getSource());
   res.setStartPoint(orig.getStartPoint());
   res.setValidLength(orig.getValidLength());
   res.setValidOffset(orig.getValidOffset());
   return res;
 }