}
}
private void removeImport(LineColRange range) {
PsiDocumentManager manager = PsiDocumentManager.getInstance(psiFile.getProject());
Document document = manager.getDocument(psiFile);
if (document == null)
return;
manager.commitDocument(document);
TextRange textRange = range.getRange(psiFile);
int start = textRange.getStartOffset();
int end = textRange.getEndOffset();
int line = document.getLineNumber(end);
int lineStart = document.getLineStartOffset(line);
int lineEnd = document.getLineEndOffset(line);
String functionName = document.getText(textRange);
String importLine = document.getText().substring(lineStart, lineEnd);
int rightWhites = getWhites(Pattern.compile(".*" + functionName + "([ ]*,[ ]*).*"), importLine);
if (rightWhites == 0) {
start -= getWhites(Pattern.compile(".*(,[ ]*)" + functionName + ".*"), importLine);
} else {
end += rightWhites;
}
boolean isEndOfLine = document.getLineEndOffset(line) == end;
int endOffset = isEndOfLine ? end + document.getLineSeparatorLength(line) : end;
document.replaceString(start, endOffset, "");
}
};
}