From c0fdff96230cef9648a61b105f60fe21fabcafb0 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Mon, 3 Oct 2016 17:46:06 +0300 Subject: [PATCH] fix npe while conversion of psi to compiler element --- .../compiler/CompilerReferenceServiceImpl.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/CompilerReferenceServiceImpl.java b/java/compiler/impl/src/com/intellij/compiler/CompilerReferenceServiceImpl.java index 7abb8229bb16..5542f66ce74b 100644 --- a/java/compiler/impl/src/com/intellij/compiler/CompilerReferenceServiceImpl.java +++ b/java/compiler/impl/src/com/intellij/compiler/CompilerReferenceServiceImpl.java @@ -186,9 +186,14 @@ public class CompilerReferenceServiceImpl extends CompilerReferenceService { if (myDirtyScope.contains(vFile)) { return null; } - CompilerElement[] compilerElements = place == ElementPlace.SRC - ? new CompilerElement[]{adapter.asCompilerElement(element)} - : adapter.libraryElementAsCompilerElements(element); + CompilerElement[] compilerElements; + if (place == ElementPlace.SRC) { + final CompilerElement compilerElement = adapter.asCompilerElement(element); + compilerElements = compilerElement == null ? CompilerElement.EMPTY_ARRAY : new CompilerElement[]{compilerElement}; + } + else { + compilerElements = adapter.libraryElementAsCompilerElements(element); + } if (compilerElements.length == 0) return null; synchronized (myLock) {