public static boolean canModify(PsiElement element) {
    VirtualFile virtualFile = PsiUtilCore.getVirtualFile(element);
    PsiFile containingFile = element.getContainingFile();
    return element.getManager().isInProject(element)
           || ScratchUtil.isScratch(virtualFile)
           || (containingFile != null && containingFile.getViewProvider().getVirtualFile().getFileSystem() instanceof NonPhysicalFileSystem);
  }
public static boolean canModify(PsiElement element)