private int findFieldInsertIndex(
     List<BodyDeclaration> decls, FieldDeclaration newDecl, int maxOffset) {
   if (maxOffset != -1) {
     for (int i = decls.size() - 1; i >= 0; i--) {
       BodyDeclaration curr = decls.get(i);
       if (maxOffset > curr.getStartPosition() + curr.getLength()) {
         return ASTNodes.getInsertionIndex(newDecl, decls.subList(0, i + 1));
       }
     }
     return 0;
   }
   return ASTNodes.getInsertionIndex(newDecl, decls);
 }