fix EA-97656 - NPE: SingleRootFileViewProvider.findElementAt

This commit is contained in:
peter
2017-02-25 20:23:13 +01:00
parent 016cdb34ce
commit 7316d13f05
@@ -447,6 +447,7 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi
return document;
}
@SuppressWarnings("MethodDoesntCallSuperMethod")
@Override
public FileViewProvider clone() {
final VirtualFile origFile = getVirtualFile();
@@ -513,10 +514,8 @@ public class SingleRootFileViewProvider extends UserDataHolderBase implements Fi
@Nullable
public static PsiElement findElementAt(@Nullable PsiElement psiFile, final int offset) {
if (psiFile == null) return null;
ASTNode treeElement = psiFile.getNode().findLeafElementAt(offset);
return SourceTreeToPsiMap.treeElementToPsi(treeElement);
ASTNode node = psiFile == null ? null : psiFile.getNode();
return node == null ? null : SourceTreeToPsiMap.treeElementToPsi(node.findLeafElementAt(offset));
}
public void forceCachedPsi(@NotNull PsiFile psiFile) {