return getInsertionIndex(container, member.getNodeType(), isStatic(member));
int defaultIndex= container.size(); int memberType= member.getNodeType(); int memberModifiers= member.getModifiers();  switch (memberType) { case ASTNode.TYPE_DECLARATION: case ASTNode.ENUM_DECLARATION : case ASTNode.ANNOTATION_TYPE_DECLARATION : case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION: case ASTNode.INITIALIZER: { int insertPos= -1; int i= 0; for (Iterator iter= container.iterator(); iter.hasNext(); i++) { int nodeType= ((BodyDeclaration)iter.next()).getNodeType(); switch (nodeType) { case ASTNode.TYPE_DECLARATION: case ASTNode.INITIALIZER: case ASTNode.ENUM_DECLARATION : case ASTNode.ANNOTATION_TYPE_DECLARATION: case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION: if (nodeType == memberType) insertPos= i + 1; break; default: if (insertPos == -1) insertPos= i; } } if (insertPos != -1) return insertPos; return defaultIndex; } case ASTNode.FIELD_DECLARATION: { int normalFieldInsertPos= -1; int staticFieldInsertPos= -1; int finalStaticFieldInsertPos= -1; int i= 0; for (Iterator iter= container.iterator(); iter.hasNext(); i++) { ASTNode node= (ASTNode)iter.next(); int nodeType= node.getNodeType(); switch (nodeType) { case ASTNode.FIELD_DECLARATION: int modifiers=((FieldDeclaration) node).getModifiers(); normalFieldInsertPos= i + 1; if (Modifier.isStatic(modifiers)) { staticFieldInsertPos= i + 1; if (Modifier.isFinal(modifiers)) { finalStaticFieldInsertPos= i + 1; } else if (finalStaticFieldInsertPos == -1) { finalStaticFieldInsertPos= i; } } else if (staticFieldInsertPos == -1) { staticFieldInsertPos= i; } break; case ASTNode.METHOD_DECLARATION: case ASTNode.INITIALIZER: if (normalFieldInsertPos == -1) normalFieldInsertPos= i; break; } } if (Modifier.isStatic(memberModifiers) && Modifier.isFinal(memberModifiers) && finalStaticFieldInsertPos != -1) return finalStaticFieldInsertPos; if (Modifier.isStatic(memberModifiers) && staticFieldInsertPos != -1) return staticFieldInsertPos; if (normalFieldInsertPos != -1) return normalFieldInsertPos; return defaultIndex; } case ASTNode.METHOD_DECLARATION: { int normalMethodInsertPos= -1; int constructorInsertPos= -1; int staticMethodInsertPos= -1; int i= 0; for (Iterator iter= container.iterator(); iter.hasNext(); i++) { ASTNode node= (ASTNode)iter.next(); int nodeType= node.getNodeType(); switch (nodeType) { case ASTNode.METHOD_DECLARATION: MethodDeclaration curr= (MethodDeclaration) node; normalMethodInsertPos= i + 1; if (curr.isConstructor()) { constructorInsertPos= i + 1; } else if (constructorInsertPos == -1) { constructorInsertPos= i; } if (Modifier.isStatic(curr.getModifiers())) { staticMethodInsertPos= i + 1; } else if (staticMethodInsertPos == -1) { staticMethodInsertPos= i; } break; } } if (Modifier.isStatic(memberModifiers) && staticMethodInsertPos != -1) return staticMethodInsertPos; if ((((MethodDeclaration) member).isConstructor()) && constructorInsertPos != -1) return constructorInsertPos; if (normalMethodInsertPos != -1) return normalMethodInsertPos; return defaultIndex; } } return defaultIndex;
	public static int getInsertionIndex(BodyDeclaration member, List container) {		return getInsertionIndex(container, member.getNodeType(), isStatic(member));	}