diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java index f099bf1ccabd..970dc0459783 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaCompletionUtil.java @@ -665,9 +665,15 @@ public class JavaCompletionUtil { if (psiClass.isValid() && !psiClass.getManager().areElementsEquivalent(psiClass, resolveReference(ref))) { final boolean staticImport = ref instanceof PsiImportStaticReferenceElement; - PsiElement newElement = staticImport - ? ((PsiImportStaticReferenceElement)ref).bindToTargetClass(psiClass) - : ref.bindToElement(psiClass); + PsiElement newElement; + try { + newElement = staticImport + ? ((PsiImportStaticReferenceElement)ref).bindToTargetClass(psiClass) + : ref.bindToElement(psiClass); + } + catch (IncorrectOperationException e) { + return endOffset; // can happen if fqn contains reserved words, for example + } final RangeMarker rangeMarker = document.createRangeMarker(newElement.getTextRange()); documentManager.doPostponedOperationsAndUnblockDocument(document);