예제 #1
0
 /**
  * Compute the end offset of give AST node.
  *
  * @param node
  * @return
  */
 private int getEndOffset(IASTNode node) {
   IASTFileLocation fileLocation = getMaxFileLocation(node.getNodeLocations());
   if (fileLocation != null) {
     return fileLocation.getNodeOffset() + fileLocation.getNodeLength();
   }
   // fallback: use container range end
   DocumentRangeNode container = getCurrentContainer();
   Position containerRange = container.getRange();
   return containerRange.getOffset() + containerRange.getLength();
 }
예제 #2
0
 /**
  * Compute the start offset of given AST node.
  *
  * @param node
  * @return
  */
 private int getStartOffset(IASTNode node) {
   IASTFileLocation fileLocation = getMinFileLocation(node.getNodeLocations());
   if (fileLocation != null) {
     return fileLocation.getNodeOffset();
   }
   DocumentRangeNode container = getCurrentContainer();
   Object[] children = container.getChildren();
   if (children != null && children.length > 0) {
     Position prevRange = ((DocumentRangeNode) children[children.length - 1]).getRange();
     return prevRange.getOffset() + prevRange.getLength();
   }
   // fallback: use container range start
   Position containerRange = container.getRange();
   return containerRange.getOffset();
 }