示例#1
0
 /**
  * Returns comments for the given node.
  *
  * @param node the node
  * @param pos the position of the comments
  * @return All comments assigned to the node at this position
  * @since 5.3
  */
 public List<IASTComment> getComments(IASTNode node, CommentPosition pos) {
   switch (pos) {
     case leading:
       return fCommentMap.getLeadingCommentsForNode(node);
     case trailing:
       return fCommentMap.getTrailingCommentsForNode(node);
     case freestanding:
       return fCommentMap.getFreestandingCommentsForNode(node);
   }
   return fCommentMap.getLeadingCommentsForNode(node);
 }
示例#2
0
 private int getEndOffsetIncludingTrailingComments(IASTNode node) {
   int endOffset = 0;
   while (true) {
     IASTFileLocation fileLocation = node.getFileLocation();
     if (fileLocation != null) endOffset = Math.max(endOffset, endOffset(fileLocation));
     List<IASTComment> comments = commentMap.getTrailingCommentsForNode(node);
     if (!comments.isEmpty()) {
       for (IASTComment comment : comments) {
         int commentEndOffset = endOffset(comment);
         if (commentEndOffset >= endOffset) {
           endOffset = commentEndOffset;
         }
       }
     }
     IASTNode[] children = node.getChildren();
     if (children.length == 0) break;
     node = children[children.length - 1];
   }
   return endOffset;
 }