EA-83566 Check that the file is still valid when Pep8ExternalAnnotator#apply() is...
authorMikhail Golubev <mikhail.golubev@jetbrains.com>
Mon, 29 Aug 2016 14:31:30 +0000 (17:31 +0300)
committerMikhail Golubev <mikhail.golubev@jetbrains.com>
Mon, 29 Aug 2016 17:30:12 +0000 (20:30 +0300)
It's perfectly normal that by the time apply() is called the original
file might have become invalid, since pycodestyle.py can take some time
to execute and the launch of the helper is itself postponed.

python/src/com/jetbrains/python/validation/Pep8ExternalAnnotator.java

index af08f42538bd88e556bf42a2e2d144ebc790ff29..cc878947e19ae3c51f3861930ceb2acb1b969209 100644 (file)
@@ -237,8 +237,7 @@ public class Pep8ExternalAnnotator extends ExternalAnnotator<Pep8ExternalAnnotat
 
   @Override
   public void apply(@NotNull PsiFile file, Results annotationResult, @NotNull AnnotationHolder holder) {
-    if (annotationResult == null) return;
-    PyPsiUtils.assertValid(file);
+    if (annotationResult == null || !file.isValid()) return;
     final String text = file.getText();
     Project project = file.getProject();
     final Document document = PsiDocumentManager.getInstance(project).getDocument(file);