"is null when called from inspection") final Editor editor,
@NotNull PsiElement startElement, @NotNull PsiElement endElement) {
if (!(startElement instanceof GoPackageDeclaration))
return;
final GoPackageDeclaration packageDeclaration = (GoPackageDeclaration) startElement;
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
Document doc =
PsiDocumentManager.getInstance(project).getDocument(file);
if (doc == null) {
return;
}
TextRange textRange = packageDeclaration.getTextRange();
doc.replaceString(textRange.getStartOffset(),
textRange.getEndOffset(),
"package " + targetPackage);
}