ThreeState (@NotNull PsiElement contextElement, @NotNull PsiFile psiFile, int offset) { if (PsiImplUtil.isLeafElementOfType(contextElement, TokenSets.STRING_LITERALS)) { PsiElement parent = contextElement.getParent(); if (parent != null) { for (PsiReference reference : parent.getReferences()) { if (!reference.isSoft() && reference.getRangeInElement().shiftRight(parent.getTextOffset()).containsOffset(offset)) { return ThreeState.NO; } } } return ThreeState.YES; } if (PsiJavaPatterns.psiElement().afterLeaf("def").accepts(contextElement)) { return ThreeState.YES; } if (contextElement.textMatches("..") || contextElement.textMatches("...")) { return ThreeState.YES; } return ThreeState.UNSURE; }