Пример #1
0
 private IASTNode getLastNodeBeforeAppendPoint(IASTNode node) {
   IASTNode[] children;
   if (node instanceof ICPPASTNamespaceDefinition) {
     children = ((ICPPASTNamespaceDefinition) node).getDeclarations(true);
   } else if (node instanceof IASTCompositeTypeSpecifier) {
     children = ((IASTCompositeTypeSpecifier) node).getDeclarations(true);
   } else {
     children = node.getChildren();
   }
   for (int i = children.length; --i >= 0; ) {
     IASTNode child = getReplacementNode(children[i]);
     if (child != null) return child;
   }
   return null;
 }
Пример #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;
 }
Пример #3
0
 public int getEndOffsetIncludingComments(IASTNode node) {
   int endOffset = 0;
   while (true) {
     IASTFileLocation fileLocation = node.getFileLocation();
     if (fileLocation != null)
       endOffset =
           Math.max(endOffset, fileLocation.getNodeOffset() + fileLocation.getNodeLength());
     List<IASTComment> comments = trailingMap.get(node);
     if (comments != null && !comments.isEmpty()) {
       for (IASTComment comment : comments) {
         int commentEndOffset = ASTNodes.endOffset(comment);
         if (commentEndOffset >= endOffset) {
           endOffset = commentEndOffset;
         }
       }
     }
     IASTNode[] children = node.getChildren();
     if (children.length == 0) break;
     node = children[children.length - 1];
   }
   return endOffset;
 }
Пример #4
0
 private IASTNode getNextSiblingNode(IASTNode node) {
   IASTNode parent = node.getParent();
   IASTNode[] siblings;
   if (parent instanceof ICPPASTNamespaceDefinition) {
     siblings = ((ICPPASTNamespaceDefinition) parent).getDeclarations(true);
   } else if (parent instanceof IASTCompositeTypeSpecifier) {
     siblings = ((IASTCompositeTypeSpecifier) parent).getDeclarations(true);
   } else {
     siblings = parent.getChildren();
   }
   boolean beforeNode = false;
   for (int i = 0; i < siblings.length; i++) {
     IASTNode sibling = siblings[i];
     if (sibling == node) {
       beforeNode = true;
     } else if (beforeNode) {
       sibling = getReplacementNode(sibling);
       if (sibling != null) return sibling;
     }
   }
   return null;
 }