CompilationUnit astRoot = SharedASTProvider
.getAST(src, SharedASTProvider.WAIT_YES, null);
ASTNode node = NodeFinder.perform(astRoot, offset, 1);
MultiTextEdit edit = new MultiTextEdit();
if (node != null && node.getNodeType() == ASTNode.IMPORT_DECLARATION){
ImportDeclaration imprt = (ImportDeclaration)node;
ASTNode next = getNext(astRoot, node, lineDelim);
while (next != null && next.getNodeType() == ASTNode.IMPORT_DECLARATION){
ImportDeclaration nextImprt = (ImportDeclaration)next;
if (!ImportUtils.importsInSameGroup(separationLevel, imprt, nextImprt)){
int end =
imprt.getStartPosition() +
imprt.getLength() +
lineDelim.length();
addLineDelim(astRoot, edit, end, lineDelim);
}
next = getNext(astRoot, next, lineDelim);
imprt = nextImprt;
}
// reset imprt ref back to the one we are importing.
imprt = (ImportDeclaration)node;
ASTNode prev = getPrev(astRoot, node, lineDelim);
if (prev != null && prev.getNodeType() == ASTNode.IMPORT_DECLARATION){
ImportDeclaration prevImprt = (ImportDeclaration)prev;
if (!ImportUtils.importsInSameGroup(separationLevel, imprt, prevImprt)){
int end = prev.getStartPosition() + prev.getLength() + lineDelim.length();
addLineDelim(astRoot, edit, end, lineDelim);
}
}