EA-103170 - NPE: XmlResourceResolver.getBaseFile

This commit is contained in:
Dmitry Avdeev
2017-09-19 14:59:37 +03:00
parent 52eb2418a7
commit d563f2255d
2 changed files with 12 additions and 11 deletions
@@ -48,7 +48,7 @@ public class ValidateXmlAction extends AnAction {
@Override
public void actionPerformed(AnActionEvent e) {
final PsiFile psiFile = CommonDataKeys.PSI_FILE.getData(e.getDataContext());
if (psiFile != null) {
if (psiFile != null && psiFile.getVirtualFile() != null) {
doRunAction(psiFile);
}
}
@@ -86,26 +86,27 @@ public class ValidateXmlAction extends AnAction {
Presentation presentation = event.getPresentation();
PsiElement psiElement = CommonDataKeys.PSI_FILE.getData(event.getDataContext());
boolean flag = psiElement instanceof XmlFile;
presentation.setVisible(flag);
boolean value = psiElement instanceof XmlFile;
boolean visible = psiElement instanceof XmlFile;
presentation.setVisible(visible);
boolean enabled = psiElement instanceof XmlFile;
if (value) {
if (enabled) {
final PsiFile containingFile = psiElement.getContainingFile();
if (containingFile!=null &&
containingFile.getVirtualFile() != null &&
(containingFile.getFileType() == StdFileTypes.XML ||
containingFile.getFileType() == StdFileTypes.XHTML
)) {
value = containingFile.getUserData(runningValidationKey) == null;
enabled = containingFile.getUserData(runningValidationKey) == null;
} else {
value = false;
enabled = false;
}
}
presentation.setEnabled(value);
presentation.setEnabled(enabled);
if (ActionPlaces.isPopupPlace(event.getPlace())) {
presentation.setVisible(value);
presentation.setVisible(enabled);
}
}
}
@@ -99,9 +99,9 @@ public class ExternalDocumentValidator {
private void runJaxpValidation(final XmlElement element, Validator.ValidationHost host) {
final PsiFile file = element.getContainingFile();
if (file == null || file.getVirtualFile() == null) return;
if (myFile == file &&
file != null &&
myModificationStamp == file.getModificationStamp() &&
!ValidateXmlActionHandler.isValidationDependentFilesOutOfDate((XmlFile)file) &&
SoftReference.dereference(myInfos)!=null // we have validated before
@@ -266,7 +266,7 @@ public class ExternalDocumentValidator {
});
myHandler.doValidate((XmlFile)element.getContainingFile());
myHandler.doValidate((XmlFile)file);
myFile = file;
myModificationStamp = myFile.getModificationStamp();